I'm writing a program, however for some reason I can't reach the gameplay function from main, except I just get the following errors:
20:23: error: expected primary-expression before ']' token
Here's the code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int gameplay (int suitcase[], ofstream outputFile)
{
cout << "Here?";
return 0;
}
int main()
{
const int ARRAY_SIZE = 10;
int suitcase [ARRAY_SIZE] = {1, 10, 100, 1000, 10000, 100000, 1000000, 0, 0, 0};
ofstream outputFile;
outputFile.open ("players.txt");
gameplay(suitcase[], outputFile);
outputFile.close ();
return 0;
}
Any help would be appreciated, thanks!
In main()
function call syntax of gameply
is wrong!
gameplay(suitcase[], outputFile);
should be just:
gameplay(suitcase, outputFile);
^
removed []
[]
needed in function declaration but not at the time when you call function.
Since you already defined suitcase as an array, you shouldn't have to say suitcase[] when you pass it into the function. (or refer to it anywhere else, for that matter)
gameplay(suitcase[], outputFile);
should just be:
gameplay(suitcase, outputFile);
This should work!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.