too few arguments!!!

Hi to All!!

//I am new to cpp forum, and this is my first post.Please pardon if i have made //any mistakes while creating this thread.

I am getting error:"In function int main() too few arguments to function int val(int)" when i compile it.Can someone please help ??

#include<stdio.h>
#include<conio.h>
int val(int);
int i=0;
int main(void)
{
printf("%d",i);
i++;
val();
printf("%d",i);
val();
}
int val(int i)
{
i=100;
printf("%d",i);
i++;
}

I am declaring only one variable in function val() and also it is returning one variable too.

Can someone tell what is the correct way of declaring the variable or simply how to get rid of the error??

Last edited on
closed account (3qX21hU5)
You define the function val as int val(int); but inside main() you call the function like val(); // Missing a integer as a argument .

You are also not returning anything from your function val().

I would recommend you take a few hours and build a simple program (Even the hello world program) and make sure it compiles and runs just fine. Then start changing things to create errors in the program (Remember what you changed) and then compile it and see what errors the compiler gives you.

Then take note of these errors and what you changed that made that error. This will help you learn what the error codes mean and will save you trouble in the long run.
Last edited on
Gotcchhaa!!! Thanks for the reply ,,I deduced where i was making the mistake from what you said.

Thanks a ton!!
Topic archived. No new replies allowed.