home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C by Discovery (4th Edition)
/
C_By_Discovery_4th_Edition.tar
/
C_By_Discovery_4th_Edition
/
_DISK_
/
ch10
/
retval.c
< prev
next >
Wrap
C/C++ Source or Header
|
2005-06-16
|
1KB
|
32 lines
/* retval.c
*
* Synopsis - Requests and accepts input of a string, an int, a
* char, and a float. Echoes those quantities and
* displays return values of printf() and scanf().
*
* Objective - To allow the reader to experiment with input to
* scanf() to get a feel for when and how conversions
* are made and what feedback is provided by scanf().
*/
/* Include Files */
#include <stdio.h>
/* Constant Definitions */
#define BUF_SIZE 80
int main( void )
{
char charvar, buff[BUF_SIZE];
int intvar, printret, scanret;
float floatvar;
printf( "Enter a string, an int, a character, and a float: " );
/* Note 1 */
scanret = scanf( "%s%d%c%f", buff, &intvar, &charvar, &floatvar );
/* Note 2 */
printret = printf( "Values : %s, %d, |%c|, %5.3f\n", buff, intvar, charvar, floatvar );
printf( "printret %d, scanret %d\n", printret, scanret );
return 0;
}