i am trying to make a text based level editor in c++
and i thought i would save time by instead or writing
a lot of if statements i would use a for loop when i run
it it dose nothing so could someone show me whats wrong with
this code thanks in advance.
The cout stream buffers its output. To make sure it has written the output before you prompt for input, add cout.flush() before the call to getline().
Use a constant to set the size of the Map_code and use a for loop to read and write it. Also increment i in the "for" clause to make it clear how the loop works:
1 2 3 4 5 6 7 8 9 10 11 12
constunsigned MapSize = 10;
string Map_code [MapSize];
ifstream Map_data("Map_data.data");
cout <<"Reading file...";
for (int i=0; i < MapSize; ++i) {
Map_data >> Map_code[i];
}
for (int i=0; i < MapSize; ++i) {
cout << Map_code[i];
}
for (int i = 0; i < MapSize; ++i) {
....