PDA

View Full Version : printf a return value?



S15_88
February 26th, 2008, 10:47 PM
quick question how to you printf a return value. i'm having a total mental block haha

lets say i have the funtion fseek() that seeks to some point in a binary file then call ftell() to find the current position. how would i print out the return value of ftell()?

Thanks, ALain

mike_g
February 26th, 2008, 10:52 PM
Just call it inside the printf. Something like:

printf("%d", ftell(file));

Martin Witte
February 26th, 2008, 10:53 PM
by using google :), first hit for ftell: http://www.cplusplus.com/reference/clibrary/cstdio/ftell.html

Lster
February 26th, 2008, 10:57 PM
ftell is apparently defined like this:


long int ftell ( FILE * stream );

The printf function:


Writes to the standard output (stdout) a sequence of data formatted as the format argument specifies. After the format parameter, the function expects at least as many additional arguments as specified in format.

and is defined:


int printf ( const char * format, ... );

See the printf link below for further reference on printf and how to print certain data.

Sources:
http://www.cplusplus.com/reference/clibrary/cstdio/ftell.html
http://www.cplusplus.com/reference/clibrary/cstdio/printf.html

I haven't had time to go into any details. Is you still have problems do post back and I can help you you further. :)