943,716 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 677
  • C++ RSS
Feb 16th, 2008
0

Array help!

Expand Post »
Hi guys, I need some help with arrays.
#include <iostream>
#include <ctime>
using namespace std;

void constructArray (int [], int);
void printArray (int [], int);

const int MAX = 30;
int sizeArray = rand() % MAX;

int main()
{
    srand(time(NULL));
    
    int makeArray [sizeArray];
    
    constructArray [makeArray, sizeArray];
    printArray [makeArray, sizeArray];
    
    system ("pause");
    return 0;
    
}

void constructArray (int makeArray [], int size)
{
     for (int i = 0; i < size; i++)
     makeA [i] = rand () % size;
     
     
 }
 
void printA (int makeArray [] , int size)
{
     for (i = 0; i < sizeA; i++)
     cout << makeA[i] << " ";
     
     
 }

I keep getting a compile error when trying to run it.
I think that my declaration is wrong but can't figure out what's wrong.
Thanks for helping.

Edit: Forgive my eyesight, spotted the [] instead of ()
Haha...
Last edited by dexter1984; Feb 16th, 2008 at 5:36 am.
Similar Threads
Reputation Points: 31
Solved Threads: 2
Light Poster
dexter1984 is offline Offline
49 posts
since Jan 2008
Feb 16th, 2008
1

Re: Array help!

Click to Expand / Collapse  Quote originally posted by dexter1984 ...
Hi guys, I need some help with arrays.
#include <iostream>
#include <ctime>
using namespace std;

void constructArray (int [], int);
void printArray (int [], int);

const int MAX = 30;
int sizeArray = rand() % MAX;

int main()
{
    srand(time(NULL));
    
    int makeArray [sizeArray];
    
    constructArray [makeArray, sizeArray];
    printArray [makeArray, sizeArray];
    
    system ("pause");
    return 0;
    
}

void constructArray (int makeArray [], int size)
{
     for (int i = 0; i < size; i++)
     makeA [i] = rand () % size;
     
     
 }
 
void printA (int makeArray [] , int size)
{
     for (i = 0; i < sizeA; i++)
     cout << makeA[i] << " ";
     
     
 }

I keep getting a compile error when trying to run it.
I think that my declaration is wrong but can't figure out what's wrong.
Thanks for helping.

Edit: Forgive my eyesight, spotted the [] instead of ()
Haha...
Function call operator is () not []. There are few undeclared variables and some variables with incorrect names.
SpS
Reputation Points: 70
Solved Threads: 32
Posting Pro
SpS is offline Offline
598 posts
since Aug 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: Need advice for data storage
Next Thread in C++ Forum Timeline: Array/ Recursive Problem





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


Follow us on Twitter


© 2011 DaniWeb® LLC