Printf
The printf function writes a formatted string to standard output. A formatted string is the result of replacing placeholders with their values. It sounds a little complicated, but with an example it will become very clear:
printf("Hello, my name is %s and I am %d years old.", "Andreas", 22);
%s %d , . man ( ) , % d () % s ().
, , . , undefined ( , - : , , ..):
printf("Hello, I'm %s years old.", 22);
, C .
gets : .
:
char name[512];
printf("What your name? ");
gets(name);
, , name.
gets() . , , .
:
gets(). , , gets() , gets() , . . fgets() .
: , , , (name ), , , , gets . undefined, .
, , , gets() . .
, fgets. , gets, size, :
char *fgets(char *s, int size, FILE *stream);
, :
char name[512];
printf("What your name? ");
fgets(name, sizeof(name) , stdin );