Array help!

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2008
Posts: 49
Reputation: dexter1984 is an unknown quantity at this point 
Solved Threads: 2
dexter1984 dexter1984 is offline Offline
Light Poster

Array help!

 
0
  #1
Feb 16th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: Array help!

 
1
  #2
Feb 16th, 2008
Originally Posted by dexter1984 View 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...
Function call operator is () not []. There are few undeclared variables and some variables with incorrect names.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 511 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC