What is wron with my code?:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int i;
void myfunc(char scrpt);
char scrpt;
char scpt[10][200];
int junk;
int main()
{
int z;
char scpt[10][200] = {
"AAA", "A1",
"BBB", "B1",
"CCC", "C1",
"DDD", "D1",
"EEE", "E1" };
srand((unsigned)time(NULL));
z = rand()%1-10;
i = z;
myfunc(scrpt);
cout << "Well done!\n" << endl;
return 0;
}
void myfunc(char scrpt[i])
{
if (i = 0, i < 5, i++)
{
cout << scpt[i] << endl;
cout << "\n";
cout << "Press ENTER if you are ready to reveal c/v.\n" << endl;
cin >> junk;
cout << "\n";
cout << scpt[i++] << endl;
cout << "\n";
cout << "\n";
cout << "\n";
}
}
///////////////////////////////////////////////////////////
I am using Visual C++. The output reads as follows:
1>------ Build started: Project: eggberto-test, Configuration: Debug Win32 ------
1> eggberto test
1>c:\documents and settings\eggberto\my documents\visual studio 2010\projects\helloworlddd\helloworlddd\eggberto test(32): error C2057: expected constant expression
1>c:\documents and settings\eggberto\my documents\visual studio 2010\projects\helloworlddd\helloworlddd\eggberto test(32): error C2466: cannot allocate an array of constant size 0
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I realize that my current problem is passing my array to the function. Any help on that part? Thanks!