Beruflich Dokumente
Kultur Dokumente
P R I N T F ( ) , S C A N F ( )
C O N V E R S I O N S P E C I F I E R S
E S C A P E S E Q U E N C E S
To print a message:
printf("This is a message\n");
Output:
1 plus 2 is equal to 3
Output:
A 65 41 101
Example :
%-6d, %5d, %6.2f
Modifier Description
- left justified
Output:
Hello
World!
Character Description
'\n' newline
'\t' horizontal tab
'\v' vertical tab
'\r' carriage return
'\x41' hexadecimal number, 0x41
'\101' octal number 101
'\0' null character - indicates the end of a string
\t \t \t\t \n
int num_students;
scanf("%d", &num_students);
Format specifiers:
%c for single characters
scanf(" %c", &some_character);
always put a space between " and % when reading characters
%d for integers
scanf ("%d", &some_integer);
%f for float
scanf ("%f", &some_float);
%lf for double
scanf ("%lf", &some_double);