Input Output Functions...
printf/scanf
~ standard C programming language functions for input and output to the console
fprintf/fscanf
~ standard C programming language functions for input and output to files
sprintf/sscanf
~ standard C programming language functions for input and output to strings
* All I/O functions are declared in the standard header file <stdio.h>.
* scanf arguments are pointers - all types must be exactly specified
printf Syntax:
printf( "format-string", expression, ... );
printf( "format-string", expression, ... );
Letter
%
d, i u o x X f, F e, E g, G a, A c s p |
Type of Matching Argument
none (outputs a % character)
int unsigned int (converts to decimal) unsigned int (converts to octal) unsigned int (converts to lower case hex) unsigned int (converts to upper case hex) double double double double int (converts to an unsigned int, displays ASCII char) string (either a string literal or an array of char) void* (converts pointer to any type) |
scanf Syntax:
scanf( "conversion-string", &variable, ... );
scanf( "conversion-string", &variable, ... );
Letter
%
d i o u x a, e, f, g c s p n [ |
Type of Matching Argument
none (outputs a % character)
int (converts strings of decimal digits to integers) int (converts strings of decimal, octal or hex to integers) unsigned int (converts strings of octal digits to integers) unsigned int (converts strings of decimal digits to integers) unsigned int (converts strings of hex digits to integers) float or double char (converts a character or string of characters) array of char void (converts a string that represents a pointer) int (stores the number of characters read from the input) array of char |