i have a text file which have the following content
n:=9
name:=vinu
here i need to take the value of n 9 and also value of name vinu
then i need to process and i need to again write in a file as the output
Ok.
can u just help me out to take the value from a text file
can u just give me a sample code
No, we cannot. We are not here to do your work for you, but we can give you pointers.
You will need to open an
fstream to read the file. In fact, since you are only wanting to read you should use
ifstream.
From there you will have to start to read and interpret the input (this is called parsing). Given the nature of the assignment I think part of what stealwings suggested is a good call in that you read in the line. Once read in, you can assign it to a string class object and use
find on it or use
strstr or strspn on the buffer directly to separate the words from the assignment operator ‘:=’ in your file.
Give it a try and let us know how you are doing. If you have additional questions, feel free to ask. If you are having problems, post the relevant code (within [code] [/code] tags please) and
point out where you are having the trouble and what that trouble is.
Good luck,
Adrian