473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 2002
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Arti Potnis | last post by:
Hi, I have an application with a function "myfunction" that opens a file and writes to it using fprintf. This application runs on a unix (sun solaris 5.8) system. I connect to this application...
5
by: google | last post by:
first, a little background... i have a C program which preprocesses some data, and then outputs the results into a text file. that text file, in turn, is used as input to a FORTRAN...
6
by: hpy_awad | last post by:
I am writing stings ((*cust).name),((*cust).address)to a file using fgets but rabish is being wrote to that file ? Look to my source please and help me finding the reason why this rabish is being...
3
by: Jim Hunter | last post by:
From what I've read, the only indication fprintf gives of an error is a negative return value. I have a series of writes to a file using fprintf, and, while I need to know if a failure has...
2
by: noleander | last post by:
Sorry if this is a trivial question :-) I've got several print statements in my code: fprintf ( stderr, ....); but when I run my program, I cannot find the output text in any window. My...
4
by: grimrob | last post by:
fprintf just is not working. I am using PHP Version 4.3.9. Whatever I do fprintf just fails. For example: fwrite($Handle, 'A1'); fprintf($Handle, 'A2); The first line always works, the...
16
by: Prayag Narula | last post by:
Hi, I want to redefine fprintf for debugging purposes. That is I want that all the output that is going to the stdout should be logged in a file. I tried something like #define fprintf...
11
by: David Mathog | last post by:
In the beginning (Kernighan & Ritchie 1978) there was fprintf, and unix write, but no fwrite. That is, no portable C method for writing binary data, only system calls which were OS specific. At...
24
by: kindrain | last post by:
the code checks whether a.txt has exact the same lines, then write different lines into b.txt Here it is: (before that ,you should creat a.txt) ---------------------- #include<stdio.h>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.