-
random file name
how would i name the file with a random name?
i get these errors when i try and compile
Code:
10 C:\Documents and Settings\wmorrish\Desktop\New Folder\main.cpp invalid conversion from `int' to `const char*'
10 C:\Documents and Settings\wmorrish\Desktop\New Folder\main.cpp initializing argument 1 of `std::basic_ofstream<_CharT,
#include <fstream>
#include <iostream>
#include <ctime>
#include <cstdio>
using namespace std;
int main()
{
srand((unsigned)time(0));
int name = rand()%3;
ofstream new_file(name, ios::app);
new_file << "leval 1" <<endl;
}
-
Reading the error message will give you clues.
10 is the line number the error was detected on. Then comes the file name, then the error itself. To use the first as an example, you're using an integer where there should be a character-type. name is declared as an integer, and in line 10 you pass it to a function that is expecting a const char* to be specific. Typecast name to a char.
-
Look up itoa() and/or std::stringstream.
Also, all this talk about game trainers etc. make me suspicious of your intents (although I could be completely wrong). Do remember that it is against the rules of the CBoard to ask questions regarding hacking, cracking, etc.
-
And if you absolutely have to ask questions about it, please make sure you understand the difference between a hacker and a cracker.