944,135 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 14047
  • C++ RSS
Apr 1st, 2007
0

too many arguments to function error message.

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jmosure is offline Offline
3 posts
since Apr 2007
Apr 1st, 2007
0

Re: too many arguments to function error message.

> 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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Apr 1st, 2007
0

Re: too many arguments to function error message.

Click to Expand / Collapse  Quote originally posted by Salem ...
> 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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jmosure is offline Offline
3 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: C++ .NET random number not getting any output
Next Thread in C++ Forum Timeline: prtnt to printer





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC