Search
&
*
Odhadněte výstupy následujících výpisů a ověřte odhady v spuštěním programu.
int x = 10; int *px = &x; printf("px = %ld\n", px); printf("*px = %d\n", *px);
Otázky k diskuzi
px
char c = 10; int x = 10; int* px = &x; char* pc = &c; printf("sizeof(c) = %ld\n", sizeof(c)); printf("sizeof(x) = %ld\n", sizeof(x)); printf("sizeof(px) = %ld\n", sizeof(px)); printf("sizeof(pc) = %ld\n", sizeof(pc));
int zabere víc místa v paměti než char.
int
char
*px
int x; char *pcx = &x; pcx[0] = 'a'; pcx[1] = 'b'; pcx[2] = 'c'; pcx[3] = '\0'; printf("x = %d\n", x); printf("&x = %ld\n", &x); printf("&x = %s\n", &x);
x
int *up, **uup, array[] = {5, -6, 0, 8, -9, 3, 1, -4}; up = array; uup = &up; printf("array[1] = %d \n", array[1]); printf("array[1] + 4 = %d \n", array[1] + 4); printf("(array + 1)[2] = %d \n", (array + 1)[2]); printf("*up = %d \n", *up); printf("*up + 4 = %d \n", *up + 4); printf("*(up + 1) = %d \n", *(up + 1)); printf("**uup = %2d \n", **uup); printf("*(*uup + 2) = %2d \n", *(*uup + 2)); printf("**uup + 4 = %2d \n", **uup + 4);
cat
echo "Hello world" | cat
Hello world
echo "Hello world" | cat2
world
\n
\t
echo "Hello world and hello again " | words
Hello world and hello again
echo "Hello world and hello again " | words-len
Hello 5 world 5 and 3 <-- hello 5 again 5
echo "Hello world" | cap
===== hELLO WORLD
tr
echo "Hello world" | tr 'Hl' 'Xk'
Xekko workd
echo "Hello world" | tr 'dweji' '01234'
H2llo 1orl0
echo "Hello world and hello again " | words | cap
hELLO WORLD AND HELLO AGAIN