delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/16/23:03:02

From: JustinFL <justinfl AT netzero DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Help with my program
Date: Mon, 16 Aug 1999 23:38:26 GMT
Organization: Deja.com - Share what you know. Learn what you don't.
Lines: 35
Message-ID: <7pa7dg$uei$1@nnrp1.deja.com>
NNTP-Posting-Host: 171.208.10.31
X-Article-Creation-Date: Mon Aug 16 23:38:26 1999 GMT
X-Http-User-Agent: Mozilla/4.61 [en] (Win95; I)
X-Http-Proxy: 1.0 x34.deja.com:80 (Squid/1.1.22) for client 171.208.10.31
X-MyDeja-Info: XMYDJUIDjustinfl
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I'm having trouble reading text from a file.  I was told to give my
program example and you guys would help.  What i'd like to know is why
this program isn't outputting a line of text from a file.  the file does
exist, i didn't add the check for file thing in there to keep it short.
But how come this isn't working.  Also, someone told me that it's not
good to use streams because they're not as good as the C routines for
reading text from a file.  I'd like some input on that.  Also, I keep
all my source files in /justin/djgpp/bin  .....is that where you all
would recommend me keeping them.  Occasionally I'll have a message pop
up saying the compiler couldn't find my source code.  If i add a path
command to my autoexec.bat file, shouldn't the compiler be able to find
the source anywhere within the PATH='s specifications.  These aren't big
problems, but I really want to know how to make the source code below
work how i want it to......:

//Start here
cout << "File.ext (12 chars max): ";
cin >> infile;
ifstream inA(infile);

if (inA)
   cout << "File opened correctly, proceeding with execution" << endl;
else
   cout << "File was not opened correctly" << endl;

char i[80];

inA >> i;
cout << i;
inA.close();
//Ends here


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019