-
February 28th, 2004, 06:51 AM
#1
Cfile::Read
I have a text file, like a data file, such as;
Text file:
This is the test.
I can easily write something like that into the text file. But the problem starts while reading. I cannot control the read parameter, I want to reach character values of this text like "T", "h", "i" and I want to seperate them to control more efficiently. What do you suggest for this situation?
-
February 28th, 2004, 06:54 AM
#2
I am not sure if I have understood u correctly. But still, why don't you try reading into a buffer first and then try doing what u want??
Muthu
-
February 28th, 2004, 07:17 AM
#3
What do you mean while saying "buffer"? It must be about handle a file CreateFile ReadFile?
I'm so sorry, but I'm so new at programming with Visual C++, I want to only read the file. Give me a trick to read a file only... it maybe some lines...
HANDLE hFile;
hFile = CreateFile("c:\\trial.txt",
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
ErrorHandler("Could not open trial.ini"); // process error
}
This is true for the beginning while read a file? And What can I do after this? Give me a small lines or example about that
-
February 29th, 2004, 09:07 PM
#4
In my CStdioFile Sample is sample code for reading from a file and writing to another file. If your file is a text file, then it is easier to use CStdioFile. Then you can use ReadString() to read each line into a CString. Using the data in the CString, you can process the text the same as any other CString.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|