Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading in one char, some white spaces, int num & some blank lines????

Status
Not open for further replies.

qb828

Programmer
Sep 27, 2000
98
US
hello! how are you?
i was able to read in one with some blank lines like this:
R 2
T -3
$ 6
3
B -1
M 2
by using get(ch) and infile >> chr >> num

but this doesn't work for some blank lines..

data file looks like :

R 2
T -3

$ 6
3
B -1

M 2

i used getline(buffer , 255, '\n')
and char * token = strtok(buffer, " ");
cout << &quot;CHAR : &quot; << token;
token = strtok(NULL, ' ');

this read in char correctly but gave me segmentation fault
look like it can't handle the bak lines
i get this print out:

CHAR : R NUM : 2
CHAR : T NUM : -3
segmentation fault



can you help me to read in thisdata file?

thanks millions

Q

 
sorry about typo!!!
i was able to read in one without some blank lines like this:
R 2
T -3
$ 6
3
B -1
M 2
by using get(ch) and infile >> chr >> num
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top