too many arguments to function error message.

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2007
Posts: 3
Reputation: Jmosure is an unknown quantity at this point 
Solved Threads: 0
Jmosure Jmosure is offline Offline
Newbie Poster

too many arguments to function error message.

 
0
  #1
Apr 1st, 2007
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:

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void readList(int nums [], int size);
  5. void printList( int list[1000]);
  6.  
  7. int main()
  8. {
  9.  
  10.  
  11. int theList[1000];
  12.  
  13. readList (theList, 5);
  14. printList (theList, 5);
  15.  
  16. return 0;
  17.  
  18. }
  19.  
  20. void printList( int list[1000])
  21. {
  22. int i;
  23.  
  24. for(i = 0; i < 1000; i++)
  25.  
  26. cout << list[i] << endl;
  27.  
  28. }
  29.  
  30. void readList(int nums [], int size)
  31. {
  32. int i;
  33.  
  34. for(i=0; i < 5; i++)
  35.  
  36. cout << "Enter the " << i + 1 << " number";
  37.  
  38. cin >> nums[i];
  39. }
Last edited by WaltP; Apr 1st, 2007 at 8:11 pm. Reason: Added CODE tags -- read the words on the background of the post input box
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: too many arguments to function error message.

 
0
  #2
Apr 1st, 2007
> 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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 3
Reputation: Jmosure is an unknown quantity at this point 
Solved Threads: 0
Jmosure Jmosure is offline Offline
Newbie Poster

Re: too many arguments to function error message.

 
0
  #3
Apr 1st, 2007
Originally Posted by Salem View Post
> 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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC