fprintf(fp,Count); gives C2664 error

J

Joy2006

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?
 
G

gustelev

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.
 
J

Jim Langston

Joy2006 said:
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);
 

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
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top