talking about fgets

This commit is contained in:
tTh
2023-07-15 09:55:13 +02:00
parent 8ba88d2b8d
commit a1f8b096e3
4 changed files with 64 additions and 2 deletions

1
code/C/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
fgets-simple

View File

@@ -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
View 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;
}