Hello all
i have a question i didnt make it please help me,
For example there is file name is myfile.txt
my name is eric
my age is 20
our company name is Goggle
********
...
there is many lines.how can i read frst line data and equal to str[100] or something
and delete a readed line in a file?
i am waiting for help
Thank you
3 replies to this topic
#1
Posted 08 January 2011 - 06:28 AM
|
|
|
#2
Posted 08 January 2011 - 08:55 AM
maybe the simplest way is to use std::vector of strings to read the whole file and then operate on the vector of strings and do whatever you want.
For instance to read the file line by line :
In the end you get vector with all the lines inside.
I am not sure if it is what you expect...
For instance to read the file line by line :
#include <vector>
#include <string>
#include <fstream>
[.......]
vector<string> temp;
fstream inp_file("myfile.txt");
while(!inp_file.eof())
{
getline(inp_file,st);
temp.push_back(st);
}
inp_file.close();
In the end you get vector with all the lines inside.
I am not sure if it is what you expect...
#3
Posted 08 January 2011 - 09:23 AM
Hi,
The above code should help you with what you're looking for. After you have read all the lines from file: you can delete the file OR re-open file with CREATE file flag.
Munir
The above code should help you with what you're looking for. After you have read all the lines from file: you can delete the file OR re-open file with CREATE file flag.
Munir
#4
Posted 10 January 2011 - 02:32 AM
Thanks for your help munir
i solved the problem in my hard way. at last.
Erkin,
i solved the problem in my hard way. at last.
Erkin,
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









