0

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];
}
2
Contributors
2
Replies
4
Views
10 Years
Discussion Span
Last Post by Jmosure
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-blocks.

Edited by mike_2000_17: Fixed formatting

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

tags.

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.