Connecting Tech Pros Worldwide Help | Site Map

fprintf(fp,Count); gives C2664 error

  #1  
Old May 26th, 2006, 06:15 AM
Joy2006
Guest
 
Posts: n/a
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?

  #2  
Old May 26th, 2006, 06:25 AM
gustelev@gmail.com
Guest
 
Posts: n/a

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.

  #3  
Old May 26th, 2006, 08:18 AM
Jim Langston
Guest
 
Posts: n/a

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