🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #121

Re: FOPEN command

#121
From: Eli Boaz
Date: Tue, 03 Nov 1992 15:26
39 lines
2054 bytes
In article <1992Nov2.213552.20766@cbnewsm.cb.att.com> wao@aluxs.att.com (BL0528540-Bill Oswald  ALC2817) writes:
>Here is a short question. If I have a line of code as follows:
>
>	stream=fopen("c:\foo\afile", "r")
>
>The resulting executable works if afile is in the same directory
>as the executable. If the above is correct the fopen command
>should be able to find afile independant of where the executable
>lives. But that does not seem to be the case. What am I doing wrong?

Change the line of code to one of the following and it should work:

  stream=fopen("c:\\foo\\afile", "r");

or

  stream=fopen("c:/foo/afile", "r");

Also, *if* you pasted the line directly from your source code,
then you're missing a semi-colon (;).  Second, personally I
would use a variable name other than "stream".  It *might* con-
flict with some other internal variable (shrug).  Third, I
normally use the slash (/) style, since BC++/TC/TC++ can use
either style (ie. using / or \\ as path seperators).  The reason
that you need double back-slashes (\\) is that the back-slash is
the "escape" character in C (and Unix).

Hope any of this helps.  (Is *this* in the FAQ?)

>BTW, I am using borland c++ 3.1
>Thanks in advance
>Bill Oswald
>wao@aluxs.att.com

-- 
ttyl,     | "My friends, no matter how rough the road maybe, we can and we  |
Eli Boaz  +---------------\ will, never, never surrender to what is right." |
raistlin@wixer.cactus.org  \  -- VP Dan Quayle to the Christian Coalition   |
wixer!raistlin@cs.utexas.edu\-----------------------------------------------+
Technical Details
Message-ID: <1992Nov3.152632.27516@wixer.cactus.org>
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!emory!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!milano!cactus.org!wixer!raistlin
References: <1992Nov2.213552.20766@cbnewsm.cb.att.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!emory!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!milano!cactus.org!wixer!raistlin
From: raistlin@wixer.cactus.org (Eli Boaz)
Subject: Re: FOPEN command
Message-ID: <1992Nov3.152632.27516@wixer.cactus.org>
Organization: Real/Time Communications
References: <1992Nov2.213552.20766@cbnewsm.cb.att.com>
Distribution: usa
Date: Tue, 3 Nov 92 15:26:32 GMT
Lines: 39