Connecting Tech Pros Worldwide Forums | Help | Site Map

fprintf(fp,Count); gives C2664 error

Joy2006
Guest
 
Posts: n/a
#1: May 26 '06
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?


gustelev@gmail.com
Guest
 
Posts: n/a
#2: May 26 '06

re: fprintf(fp,Count); gives C2664 error


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.

Jim Langston
Guest
 
Posts: n/a
#3: May 26 '06

re: fprintf(fp,Count); gives C2664 error



"Joy2006" <shubhabk@gmail.com> wrote in message
news:1148620589.623873.196890@j73g2000cwa.googlegr oups.com...[color=blue]
>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?[/color]

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);


Closed Thread