File Read/Write buffer lenght
-
I have a file in which I write some names. lets say: Fiat, Ford, BMW. How can I open the file and read the entries one by one. eg: if only want to read Fiat and Ford then read only Fiat and Ford.
-
I have a file in which I write some names. lets say: Fiat, Ford, BMW. How can I open the file and read the entries one by one. eg: if only want to read Fiat and Ford then read only Fiat and Ford.
-
I have a file in which I write some names. lets say: Fiat, Ford, BMW. How can I open the file and read the entries one by one. eg: if only want to read Fiat and Ford then read only Fiat and Ford.
How are you trying to open a FILE? Using FILE * - fread(),fgetc(),fscanf(). CFile::Read(). CStdioFile::ReadString()- these classes have methods to read from the file.
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
Thanks a lot it works using ReadString(). But how can I edit the file and replace Fiat with Mercedes, let's say?
-
I have a file in which I write some names. lets say: Fiat, Ford, BMW. How can I open the file and read the entries one by one. eg: if only want to read Fiat and Ford then read only Fiat and Ford.
In additional you can use
CFile m_file(m_Filename,CFile::modeRead); CArchive m(&m_file,CArchive::load); m.ReadString(str); ....
_**
**_
WhiteSky
-
Thanks a lot it works using ReadString(). But how can I edit the file and replace Fiat with Mercedes, let's say?
tanarnelinistit wrote:
how can I edit the file and replace Fiat with Mercedes
this is a little bit difficult. here Mercedes have more characters than Fiat. U cannot insert character in a file in any place other that EOF. But replacing Fiat with a word of same character is possible. Move the file pointer to the begining of the word using CFile::Seek() function. then use CFile::Write() to replace it.
nave
-
Thanks a lot it works using ReadString(). But how can I edit the file and replace Fiat with Mercedes, let's say?
Read each of the lines from the "old" file into the "new" file up to the line that needs to be changed. Write the line into the "new" file. Read the remaining lines from the "old" file into the "new" file. Close both files. Delete the "old" file. Rename the "new" file. Make sense?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb