bricolages...
This commit is contained in:
10
code/C/Makefile
Normal file
10
code/C/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
# exemples pour le chapitre sur le C
|
||||
# new Sat Feb 11 12:06:34 CET 2023
|
||||
|
||||
no-op: no-op.c Makefile
|
||||
gcc -Wall $< -o $@
|
||||
|
||||
slowprint: slowprint.c Makefile
|
||||
gcc -Wall $< -o $@
|
||||
|
||||
18
code/C/no-op.c
Normal file
18
code/C/no-op.c
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* no-op.c is an useless shell filter
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int quux, baz;
|
||||
|
||||
while (EOF != (quux=getchar())) {
|
||||
baz = toupper(quux);
|
||||
if ('O'==baz || 'P'==baz) continue;
|
||||
putchar(quux);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
20
code/C/slowprint.c
Normal file
20
code/C/slowprint.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
struct timespec ts;
|
||||
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 115 * 1000 * 1000;
|
||||
while ( EOF != (c=getchar()) )
|
||||
{
|
||||
putchar(c);
|
||||
fflush(stdout);
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user