470,815 Members | 1,103 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

fprintf(fp,Count); gives C2664 error

I am a beginner of VC++...
Whenever I use fprintf(fp,Count); where Count is a Long Variable, I get
an error saying
"error C2664: 'fprintf' : cannot convert parameter 2 from 'long' to
'const char *'"

Can someone help me?

May 26 '06 #1
2 1886
fprintf is used for output in file.
So, first argument will be file pointer, second - formatting string
like "%d", and third will be your Long Variable.
I don't remember what exactly you must put in formatting string in this
case, please use manual.

May 26 '06 #2

"Joy2006" <sh******@gmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
I am a beginner of VC++...
Whenever I use fprintf(fp,Count); where Count is a Long Variable, I get
an error saying
"error C2664: 'fprintf' : cannot convert parameter 2 from 'long' to
'const char *'"

Can someone help me?


printf would be
printf("%ld", Count);

(%d is for int, %ld is long int)

But, fprintf wants the file to print to as the first paramater, so you just
scoot everything over.

fprintf(fp, "%ld", Count);
May 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Arti Potnis | last post: by
2 posts views Thread by noleander | last post: by
4 posts views Thread by grimrob | last post: by
16 posts views Thread by Prayag Narula | last post: by
24 posts views Thread by kindrain | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.