| scanf1.c - Illustration af directives med almindelige tegn, samt brug af scan width. | Lektion 10 - slide 19 : 28 Program 1 |
#include <stdio.h>
int main (int argc, char *argv []){
int scan_res;
double double_number;
char str[7];
printf("Indtast et $ efterfulgt af en double.\n");
scan_res = scanf("$%lf", &double_number);
printf("Det indlæste tal: %f\n", double_number);
printf("scanf returnerede: %d\n", scan_res);
printf("Indtast en streng - der læses max 6 tegn\n");
scan_res = scanf("%6s", str);
printf("Den indlæste streng: %s\n", str);
printf("scanf returnerede: %d\n", scan_res);
}