I'm interested in making a level maker program. I need to be able to read specific data from that file and convert it to strings and ints.
file.txt
// string sprite, int x, int y, int z
tree1 40 30 1
tree2 50 35 2
I need to convert each string to proper variable using a space(I could change it to anything at this point).
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("file.txt");
int linnum=0;
char c;
while (myfile.good()) {
c = myfile.get();
if (c=='\n')linnum++;
}
myfile.close();
cout<<linnum<<endl;
return 0;
}
So I want it in an array. So I made this to get the number of lines for the array.
I need an array that can hold a sting and three ints.