943,981 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1976
  • C++ RSS
Apr 22nd, 2007
0

Re: Reading a text file character by character and line by line

Expand Post »
hi every one,
im working on a project which is the assembler of SIC language,im using a mixture of c and c++ functions in my c++ program by including <stdio.h> and <iostream.h>header files....
my problem is that im reading from file,this file contains the source code of SIC language...i want to read it line by line divide each line into tokens,,,,,i used strtok and it divided only the first line of the file,,i want to move to the next line,,,,i put a loop but it does not work,,,,,,,what shall i do,,,,,,,plz i nees an answer as soon as possible
the folowing is the part of code which divides only the first line:

fgets(string,100,source_code);
label=strtok(string," ");
mnemonic=strtok(NULL," ");
operand=strtok(NULL,"\n");


cout<<label<<"\n"<<mnemonic<<"\n"<<operand<<"\n";
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
banan is offline Offline
1 posts
since Apr 2007
Apr 22nd, 2007
0

Re: Reading a text file

moved
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Assistance with change program
Next Thread in C++ Forum Timeline: Help with function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC