![]() |
|
#1
|
|||
|
|||
C++ string from filehi everyone!
i have a code that reads from a text file and according to the CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
thanks!! |
|
#2
|
||||
|
||||
|
To read the entire line you can use getline() instead. the ">>" operator stops at whitespace.
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#3
|
|||
|
|||
|
my text file is stg like this
00 Print give me 3 integers to operate 01 Input x 02 Input y 03 Input z 04 Let x=(x+y+z)/3 05 Print x 06 End So actually i want to take them seperately as index, command and string but as the case like the first line i want to store all "give me 3 integers to operate" as string what should i do for that case?? is it possible to take the first 2 with >> and then take them charachter by character till the end of the line? |
|
#4
|
|||
|
|||
|
Based on the code you've got, I assume this is a basic interpreter.
Now, what you could do instead of, CPP / C++ / C Code:
...is to have each case statement handle what is expected after the different types of komut... (especially if you intend to extend this interpreter further... you may have other tokens that don't require strings after them.) So, instead: CPP / C++ / C Code:
That said, your code in its current state will not compile... switch cases can't use strings to my knowledge... instead of using 'switch' I used 'if' and 'if else' statements with strcmp() tests when compiling the code. Also, remeber to close your file at the end of the program... |
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CD Burner Help - Power Calibration Error.... | JonBoy420 | Computer Hardware Forum | 110 | 05-Feb-2008 19:34 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 11:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 12:28 |
| Re: Programming Techniques | WaltP | C Programming Language | 0 | 10-Mar-2004 00:56 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The