Computing.Net > Forums > Programming > Win32: Reading a texts from a file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Win32: Reading a texts from a file

Reply to Message Icon

Name: John Raul II Joven
Date: November 15, 2004 at 21:07:26 Pacific
OS: Win XP
CPU/Ram: 924 oc'd P3 Coppermine
Comment:


I am programming a role-playing game from DOS to Win32 using Microsoft Visual C++ 6 environment. Recently, I have a problem reading texts from files. I've attempted already the various methods to read a file. Actually, I know how to read a file as a whole using fopen(), however, my app is turning crazy: it also reads extra texts that I do not understand. Can you please help me find a good reading a text from file for Win32 apps?

Another question, my VC++6 do not recognize the getline() function even if I already added the <string> and <iostream> header files. I want to use the string class and getline() function that I have used once before using Borland C++ 5.02 compiler.
Thanks guys!!!

Note: My game is a text game but hopefully, it will include some graphics when I successfully port it to Win32. During it's DOS time, it was like Bots. See bots2.net

Thanks!

anmjoven



Sponsored Link
Ads by Google

Response Number 1
Name: John Raul II Joven
Date: November 15, 2004 at 21:15:05 Pacific
Reply:

Oops, wrong grammar! (accident)
I mean "Win32: Reading texts from a file"

anmjoven


0

Response Number 2
Name: tImmaY
Date: November 17, 2004 at 21:37:59 Pacific
Reply:

#include <fstream>

^ add that
v and this

char buffer[256];
ifstream readIn ("file.txt");
if (! readIn.is_open())
{ cout << "Error opening file"; exit (1); }

while (! readIn.eof() )
{
readIn.getline (buffer,256);
cout << buffer << endl;
}

incorporate that. :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Win32: Reading a texts from a file

read from a file... Fortran or C www.computing.net/answers/programming/read-from-a-file-fortran-or-c/576.html

Read all lines from a txt file www.computing.net/answers/programming/read-all-lines-from-a-txt-file/19395.html

Reading from a file and executing www.computing.net/answers/programming/reading-from-a-file-and-executing/19675.html