#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
void GiveNamesMaps(){
autoint amount;
auto ofstream file;
auto string level_header = "map ", level_name="-none-";
cout << "How many level names you would like to give: ";
cin >> amount;
file.open("defs_levels.def");
for(int i=0; i <= amount; i++){
file << level_header;
cout << "Give level name for level " << i << ": ";
getline(cin,level_name);
i < 10 ? file << 0 << i : file << i;
file << " " << level_name << endl;
}
file.close();
}
int main(){
cout << "Script Manager:\n\n";
GiveNamesMaps();
return 0;
}
The goal of this program is to create output file "defs_levels.def" and contain data like this:
1 2 3 4
map 00 Hub World
map 01 Level 1
map 02 Another level
map 03 Third level
etc.
Of course I add the file name into output file later on too, but getline doesn´t seem to work correctly. Now when I run this it doesn´t allow me to give a name for level 00. Help, please.