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

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Win32: Reading a texts from a file

Reply to Message Icon

Original Message
Name: John Raul II Joven
Date: November 15, 2004 at 21:07:26 Pacific
Subject: Win32: Reading a texts from a file
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


Report Offensive Message For Removal


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

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

anmjoven


Report Offensive Follow Up For Removal

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

#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. :)


Report Offensive Follow Up For Removal







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








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software