Reading columns from text file

How can I read just the first column of this from a text file?

1
2
3
4
5
6
7
8
	   ORG	       100
 	   LOAD	       X
 	   ADD	       Y
 	   STORE       Z
 	   HALT	
X,	   DEC	       49
Y,	   DEC	       -80
Z,	   HEX	       0000


I have
1
2
3
4
5
6
7
8
9
while (! sourceCode.eof() )
{
getline(sourceCode,symbolValue,'\n');

sourceCode >> symbolValue >> codeWord >> value;

symbolTable << symbolValue << endl;

}
Last edited on
Read it line by line and if line does not start with space, read first value from it with sscanf for example.

What you are doing is really wrong since you are reading line (without using results) then you are reading three values from next line... then line again... mess
Answered in the duplicate thread.

http://www.cplusplus.com/forum/general/114085/
Topic archived. No new replies allowed.