954,198 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

too many arguments to function error message.

hello everyone I am trying to create an array that will prompt the user for 5 numbers in the array and simply display them. but I keep geting this error message saying i have too many arguments in my function... please help. here is my code:

#include <iostream>
using namespace std;
 
void  readList(int nums [], int size);
void  printList( int list[1000]);
 
int main()
{
   
     
   int theList[1000];
 
 readList (theList, 5); 
  printList (theList, 5);
  
  return 0;
    
} 
 
void printList( int list[1000])
{
     int i;
     
     for(i = 0; i < 1000; i++)
     
     cout << list[i] << endl;
    
} 

void  readList(int nums [], int size)
{
      int i;
      
      for(i=0; i < 5; i++)
      
      cout << "Enter the " << i + 1 << " number";
      
      cin >> nums[i];
}
Jmosure
Newbie Poster
3 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

> void readList(int nums [], int size);
> void printList( int list[1000]);
Notice what's different ?

The 1000 isn't actually doing anything useful (nor is it actually harmful either). It certainly has nothing to do with the size of the array being passed.

Also, read the intro threads and how to use [code][/code] tags.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 
> void readList(int nums [], int size); > void printList( int list[1000]); Notice what's different ? The 1000 isn't actually doing anything useful (nor is it actually harmful either). It certainly has nothing to do with the size of the array being passed. Also, read the intro threads and how to use tags.



thank you. I messed around with it and I just forget to include the size in the function prototype.

Jmosure
Newbie Poster
3 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You