By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,434 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,434 IT Pros & Developers. It's quick & easy.

What is wrong with this call?

P: n/a
-----------------
fopen(c:\try\clip1.dat, r);
----------------
Nov 18 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"c.lang.mys...@gmail.com" <c.lang.mys...@gmail.comwrote:
-----------------
fopen(c:\try\clip1.dat, r);
----------------
Three problems at least. First, you put your question in
the subject line alone. Second, you're using so called
smart quotes in C code. Fix those and you're ready to
be directed to the FAQ (q19.17) for the third issue.

--
Peter
Nov 18 '08 #2

P: n/a
"c.***********@gmail.com" <c.***********@gmail.comwrites:

It helps if you put the question in the body of the post: "What is
wrong with this call?"
fopen(”c:\try\clip1.dat”, “r”);
I was surprised to see that this is not a FAQ (unless I missed it).
To put \ into a C string literal you need to write \\. The sequence
\t is a tab character and \c is undefined. You can also side-step the
problem since almost every C library accepts / as an alternative in
file names.

Also, you have the wrong quotes. You need "..." not the characters
you have. These may simply have been inserted by your posting
software so it may not be an issue in your code.

--
Ben.
Nov 18 '08 #3

P: n/a
Peter Nilsson <ai***@acay.com.auwrites:

<snip>
>... Fix those and you're ready to
be directed to the FAQ (q19.17) for the third issue.
Drat. I did miss it!

--
Ben.
Nov 18 '08 #4

P: n/a
c.***********@gmail.com wrote:
-----------------
fopen(c:\try\clip1.dat, r);
----------------
Firstly, the quotes look funny.

Secondly, '\' character in C string literals (and character constants)
is a escape character. Use '\\' to represent the backslash character.

fopen("c:\\try\\clip1.dat", "r");

--
Best regards,
Andrey Tarasevich
Nov 18 '08 #5

P: n/a
c.***********@gmail.com wrote:
fopen(”c:\try\clip1.dat”, “r”);
\t is the escape sequence for a horizontal tab
\c is an undefined escape sequence

I doubt very much that your filename includes those characters.

There are two obvious suggestions to make:
1) If your question is worth asking, it is worth puting in the the body
of your message. Subject headers are not the place for anything
important for your message.
2) Buy any decent C text, and read the sections on character constants,
string literals, and escape sequences.
Nov 18 '08 #6

P: n/a
c.***********@gmail.com wrote:
-----------------
fopen(c:\try\clip1.dat, r);
----------------
Rotten use of quote characters?
Nov 18 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.