too few arguments to function in 'function()'

Feb 26, 2014 at 11:51am




this is my function declaration
 
    int boygroups(int ans);

and this is my function definition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    int boygroups(int ans) {             
	switch (p) {
		case 1: printf("\n\n\n\t\t\t\t1. %s\n",songs[0].una);
			printf("\t\t\t\t2. %s\n",songs[0].pangalawa);
			printf("\t\t\t\t3. %s\n",songs[0].pangatlo);
			printf("\t\t\t\t4. %s\n",songs[0].pangapat); 
			break; 
		case 2: printf("\n\n\n\t\t\t\t1. %s\n",songs[1].una);
			printf("\t\t\t\t2. %s\n",songs[1].pangalawa);
			printf("\t\t\t\t3. %s\n",songs[1].pangatlo);
			printf("\t\t\t\t4. %s\n",songs[1].pangapat); 
			break;
		case 3: printf("\n\n\n\t\t\t\t1. %s\n",songs[2].una);
			printf("\t\t\t\t2. %s\n",songs[2].pangalawa);
			printf("\t\t\t\t3. %s\n",songs[2].pangatlo);
			printf("\t\t\t\t4. %s\n",songs[2].pangapat);      
			break;
		case 4: printf("\n\n\n\t\t\t\t1. %s\n",songs[3].una);
			printf("\t\t\t\t2. %s\n",songs[3].pangalawa);
			printf("\t\t\t\t3. %s\n",songs[3].pangatlo);
			printf("\t\t\t\t4. %s\n",songs[3].pangapat);       
			break; 
	
	}        
}

My declaration and definitioon is the same, i don't know why i keem getting an error like this.
Feb 26, 2014 at 11:52am
show us how you call it.

(also, don't you want to return an int? If not, make it a void function)



edit: I see Mikey has answered your question in your other thread (http://www.cplusplus.com/forum/beginner/124653/)
Last edited on Feb 26, 2014 at 11:55am
Feb 26, 2014 at 11:56am
boygroups(); <-- i call it like this, and then i have a value to return i just forgot to write it.
Feb 26, 2014 at 11:58am
Then that's the reason. You call it without passing in an int. but you've told your compiler your method will take an int.

But i can see this is being pointed out in your other thread.
Feb 26, 2014 at 12:03pm
i don't get it, i just forget to write the return value here, but it is written in my program.
Feb 26, 2014 at 12:17pm
boygroups(); <-- i call it like this, and then i have a value to return i just forgot to write it.

This has nothing to do with the return value. You've defined your function to take an integer argument. But you're not supplying that argument when you actually call the function.

It seems to me that you really don't understand how to call functions with arguments. I recommend you go back to your textbook and re-read the section on functions, because this is of fundamental importance to writing C and C++ code, and you'll need to be sure you understand it.
Last edited on Feb 26, 2014 at 12:17pm
Topic archived. No new replies allowed.