if we have to output to stdout when should we use fprintf or printf
fprintf(stdout,"asdfa",5);
printf("asdfa");
thanx in advance....
awaiting a reply....
if we have to output to stdout when should we use fprintf or printf
fprintf(stdout,"asdfa",5);
printf("asdfa");
thanx in advance....
awaiting a reply....
Normally, If you would like to print to standard output you can go ahead with Printf, In case if you want to Print any thing to user defined Files, you can use fprintf.
There is not much difference between printf and fprintf, if your writing to standard output
Thanx,
Gobinath
Gobinath is right. Irrelevant to the question however, this is the prototype for fprintf()
so im not sure why you put a 5 hereCode:int fprintf(FILE *stream, const char *format, ...);
Code:fprintf(stdout,"asdfa",5);
fprintf(stdout, "blah");
is exactly the same as
printf("blah");
If you understand what you're doing, you're not learning anything.
Think of printf() as a "wrapper" for fprintf(stdout....)
Print formatted data to a stream.Code:int fprintf (FILE * stream , const char * format [ , argument , ...] );
Prints to the specified stream a sequence of arguments formatted as the format argument specifies.
Parameters.
stream
Pointer to an open file.
format
String that contains the text to be printed.
Optionally it can contain format tags that are substituted by the values specified in subsequent argument(s) and formatted as requested.
The number of format tags must correspond with the number of additional arguments that follows.
The format tags follow this prototype:
%[flags][width][.precision][modifiers]type
Print formatted data to stdout.Code:int printf ( const char * format [ , argument , ...] );
Prints to standard output (stdout) a sequence of arguments formatted as the format argument specifies.
Parameters.
format
String that contains the text to be printed.
Optionally it can contain format tags that are substituted by the values specified in subsequent argument(s) and formatted as requested.
The number of format tags must correspond to the number of additional arguments that follows.
The format tags follow this prototype:
%[flags][width][.precision][modifiers]type
Sorry for spelling errors, not English!
xxxrugby: "All Human Race Will Die From My Hand!"
xxxrugby: "We are all philosophers, when question is about politics!"
My Tutorials :
- Bad programming practices in : C
- C\C++ Tips
(constrcutive criticism is very welcome)
- Brain Cell