Connecting Tech Pros Worldwide Help | Site Map

fprintf(fp,Count); gives C2664 error

 
LinkBack Thread Tools Search this Thread
  #1  
Old May 26th, 2006, 05:15 AM
Joy2006
Guest
 
Posts: n/a
Default 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?


  #2  
Old May 26th, 2006, 05:25 AM
gustelev@gmail.com
Guest
 
Posts: n/a
Default 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, 07:18 AM
Jim Langston
Guest
 
Posts: n/a
Default 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);


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.