I have this in a text file:
John 20 30 40
mike 30 20 10
How do i read from the text file and separate them into variable name, var1, var2,
It looks like you need to declare var1, var2, and var3.
Also instead of this:
getline (myfile,name,'\t');
getline (myfile,var1,'\t');
getline (myfile,var2,'\t');
getline (myfile,var3,'\t');
Try this:
myfile >> name;
myfile >> var1;
myfile >> var2;
myfile >> var3;
Not because what you had is wrong, but the second is cleaner and will handle all white space.