Archived

This topic is now archived and is closed to further replies.

johnnyBravo

Using vc++/win32 app what headers etc would i use to read a text file etc

Recommended Posts

johnnyBravo    100
im using vc++ / win32application. I want to read, save etc a text file, but i cant seem to find any relevant tutorials, anyone have some code that does this or know a link would be great. Thanks.

Share this post


Link to post
Share on other sites
Peon    276
You could just read about fstream... Using it makes text i/o very easy.

[edited by - Peon on October 11, 2003 4:14:52 AM]

Share this post


Link to post
Share on other sites
DarkSlayer    100
There are some win32 api you could use than the old fstream.


HANDLE hFile;

hFile = CreateFile("MYFILE.TXT", // open MYFILE.TXT
GENERIC_READ, // open for reading
FILE_SHARE_READ, // share for reading
NULL, // no security
OPEN_EXISTING, // existing file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template

if (hFile == INVALID_HANDLE_VALUE)
{
ErrorHandler("Could not open file."); // process error
}

CloseHandle(hFile);



This is just some code I found on my disk somewhere, you will have to look up the CreateFile() function in msdn to see how it works. It does have alot of nice stuff to handle files etc..
You could also search google for CreateFile win32, I found several examples on the net.

Share this post


Link to post
Share on other sites