Search
char, int, float, double
~/prp/lab02
#include <stdio.h> int main(void) { printf("I like B0B36PRP!\n"); return 0; }
echo $?
program0
program1
./program0 && ./program1 ./program1 && ./program0
./program0 && echo $? && ./program1 && echo $? ./program1 && echo $? && ./program0 && echo $?
a dále pak
./program0 && echo $? && ./program1; echo $? ./program1; echo $? && ./program0 && echo $?
#include <stdio.h> int main(void) { printf("I like B0B36PRP!\n"); printf("I like B0B36PRP!\n"); printf("I like B0B36PRP!\n"); printf("I like B0B36PRP!\n"); return 0; }
který následně upravte využitím cyklu
#include <stdio.h> int main(void) { for (int i = 0; i < 4; ++i) { printf("I like B0B36PRP!\n"); } return 0; }
Vyzkoušejte kompilaci a spuštění programu, např.
clang program.c && ./a.out
nebo
clang program.c -o program && ./program
scanf()
int n; scanf("%d", &n);
int
int n; if (scanf("%d", &n) == 1) { printf("Parsed number is %d\n", n); } else { printf("Input number has not been parsed!\n"); }
wc
clang program.c && echo 4 | ./a.out | wc
out.c
out
echo 10 | ./out echo 10 | ./out | wc echo 10 | ./out > output.txt cat output.txt wc output.txt
in
int r, n; while ((r = scanf("%d", &n)) == 1) { // increment of the counter } if (r == 0) { printf("Wrong input detected!\n"); } else { printf("Number lines %d\n", counter); }
EOT
Ctrl+D
echo 10 | ./out > output.txt ./in < output.txt
char c = 'a'; int i = 1000,j; float x,y = 3.1415; printf("%c\n", c); printf("%i\n", c); printf("%d\n", i); printf("%+5d\n", i); printf("%x\n", i); printf("%f\n", y); printf("%10.3f\n", y); printf("\t%-g\n", y);
printf("%6d,%4d", 86, 1040); printf("\n"); printf("%12.5e", 3.14159265); printf("\r"); printf("%.4f\n", 85.167);
stdout
stderr
fprintf
fprintf(stdout, "Standardní výstup: %d", i); fprintf(stderr, "Error výstup: %d", i);
./main >output.log 2>error.log
1-20.3-4.0e3
scanf("%d%d%f%f", &i, &j, &x, &y);
scanf
“%d/%d”
./main <input.log