Jump to content
  • Advertisement

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

This topic is 5396 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!