| | |
Reading a text file
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2007
Posts: 1
Reputation:
Solved Threads: 0
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";
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
- C++ Reading from a text file (C++)
- Help with a 2D array from a text file (C++)
- read text file (C)
- Reading in a text file string is not complete (Pascal and Delphi)
- reading txt file into array (C++)
Other Threads in the C++ Forum
- Previous Thread: Assistance with change program
- Next Thread: Help with function
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph homeworkhelp iamthwee ifstream input int java lib library lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sorting spoonfeeding string strings struct temperature template templates text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






