| | |
Array help!
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 49
Reputation:
Solved Threads: 2
Hi guys, I need some help with arrays.
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...
#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.
•
•
•
•
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...
![]() |
Similar Threads
- Can I ghost a RAID array??? (Windows NT / 2000 / XP)
- Creating dynamic array structures (C++)
- Array limit (C)
- struct dynamic 2d array alloc (C)
- string to integer array transformation (C)
- Array (Visual Basic 4 / 5 / 6)
Other Threads in the C++ Forum
- Previous Thread: Need advice for data storage
- Next Thread: Array/ Recursive Problem
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





