I'm working on a simple function to read in from a file called save.txt and i need to read about 7 or 8 characters in. 4 characters are numbers that represent North south east and west respectively the other 4 characters are delimiters(i don't know why i put them in maybe for easier reading?)
and the function is supposed to "load" the numbers up in int north,south,east,west; but im kinda having some trouble with that part. a little point in the right direction would be swell i have tried a combination of getline() strok() and something else(can't remember).
Short Version:
load text from a file and
assign the numbers to their respective integers.
anyway here is what I've have right now when i was messing with strok().
if(input=="load"){
char locat[8]; //location is already a string so thats why this is name locat.
char* test=NULL;
int loop=0;
cout<<"loading..\n";
load.open("save.txt");
load.getline(locat,8);
test=strtok(locat,".");
while(test!=NULL){
cout<<test<<"\n";
test=strtok(NULL,".");
}
}
and sample save.txt
3.0.0.1
//North first. South second. East third. and West fourth.