my doubts in C

C

Chris Dollin

int fp

fp = fopen ( "r , "abc.txt);;

it is giving error "file not opening"

I find this highly surprising, since the code isn't remotely
compilable.

If one hallucinates that fp is a FILE*, and that the code
appears within, say, main, and that the fopen call repairs
to

fp = fopen( "r", "abc.txt" );

to get that problem report, then I'd expect it to be because
there's no file called `r` to open.

--
"Its flagships were suns, its smallest vessels, /The City and the Stars/
planets."

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN
 
J

John Bode

int fp

fp = fopen ( "r , "abc.txt);;

it is giving error "file not opening"

Ignoring the obvious syntax errors, the problem is that you have your
parameters reversed. It *should* be

fp = fopen("abc.txt", "r");

What reference manual are you using?
 
J

John Bode

Ignoring the obvious syntax errors, the problem is that you have your
parameters reversed. It *should* be

fp = fopen("abc.txt", "r");

What reference manual are you using?

Huh. Didn't recognize that this jackass is trolling. Sorry.
 
K

Kenneth Brody

Chris said:
I find this highly surprising, since the code isn't remotely
compilable.

If one hallucinates that fp is a FILE*, and that the code
appears within, say, main, and that the fopen call repairs
to

fp = fopen( "r", "abc.txt" );

to get that problem report, then I'd expect it to be because
there's no file called `r` to open.

[Ignoring the trolling of the OP...]

7.19.5.3p3 states:

If the string is one of the following, the file is open in the
indicated mode. Otherwise, the behavior is undefined.

It is perfectly acceptable that the UB outputs "file not opening"
as a result of this, once the obvious syntax errors are "fixed",
whether or not a file named "r" exists. :)

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top