I want to load the INT from the file which is a number. Can you please show me a code? This is the code I got but this error 268 C:\Dev-Cpp\Applications - Console\Numbers\main.cpp no matching function for call to `getline(std::ifstream&, int&)'
1 2 3 4 5 6
ifstream infile;
infile.open ("pokeballs.dat");
getline(infile, a);
a = x;
infile.close();
Can you please tell me what the correct use of it might be? I don't find anything different though.
@Dput
Your code removed my errors, but it is not going to save.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int a, b, k;
ifstream infile;
infile.open ("pokeballs.dat");
infile >> a;
a = x;
infile.close();
//
infile.open ("pokemons.dat");
infile >> b;
b = y;
infile.close();
//
infile.open ("cash.dat");
infile >> k;
k = z;
infile.close();
What might the problem be? Defines are on top of the script ( start)
1 2 3 4 5 6
int c; // chances
int nn; // command for catching pokemon or buying pokeballs
int n; // second command
int x; // pokeballs
int y; //pokemons
int z; // cash
Also, my int main() is at the end of the code because that's the only way I can get my script run the other functions (other(); and game();)
^ That ain't my main problem now, but if that's what is causing errors, than I have to find a solution to it. If it isn't, than it is not opening me much problems.
You read in from the file to a, then overwrite what you've read in with whatever's in x. Did you mean to save the file value to x instead?
Also, my int main() is at the end of the code because that's the only way I can get my script run the other functions (other(); and game();)
You can have functions defined after main, but then you need to declare the function/put a function prototype before main.
See this page - scroll down to Declaring Functions. http://www.cplusplus.com/doc/tutorial/functions/