talking about fgets
This commit is contained in:
1
code/C/.gitignore
vendored
Normal file
1
code/C/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
fgets-simple
|
||||
@@ -8,3 +8,6 @@ no-op: no-op.c Makefile
|
||||
slowprint: slowprint.c Makefile
|
||||
gcc -Wall $< -o $@
|
||||
|
||||
fgets-simple: fgets-simple.c Makefile
|
||||
gcc -Wall $< -o $@
|
||||
|
||||
|
||||
14
code/C/fgets-simple.c
Normal file
14
code/C/fgets-simple.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* exemple utilisation 'fgets'
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#define TL 8
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char buffer[TL+1];
|
||||
while( fgets(buffer, TL, stdin) ) {
|
||||
printf(" %4ld\n", strlen(buffer));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user