| | |
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
Views: 511 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





