Compare commits

...

3 Commits

Author SHA1 Message Date
32e70e96ce
Up through lcthw ex12 2024-04-18 18:28:12 -04:00
8af4f619f4
Revert "Trying and failing to break ex11.c"
This reverts commit 52a5ea57e1.
2024-04-17 08:29:40 -04:00
52a5ea57e1
Trying and failing to break ex11.c 2024-04-17 08:29:30 -04:00
3 changed files with 35 additions and 2 deletions

1
lcthw/.gitignore vendored
View File

@ -5,3 +5,4 @@ ex8
ex9
ex10
ex11
ex12

View File

@ -1,7 +1,7 @@
CFLAGS ?= -Wall -g
GDBRUN = gdb --batch --ex run --ex bt --ex q --args
BUILD_TARGETS = ex1 ex3 ex7 ex8 ex9 ex10 ex11
TEST_TARGETS = ex1 ex3 ex7 ex8 ex9 ex11
BUILD_TARGETS = ex1 ex3 ex7 ex8 ex9 ex10 ex11 ex12
TEST_TARGETS = ex1 ex3 ex7 ex8 ex9 ex11 ex12
.PHONY: all
all: build test

32
lcthw/ex12.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
int main(int argc, char *argv[])
{
int areas[] = { 10, 12, 13, 14, 20 };
char name[] = "Zed";
char full_name[] = {
'Z', 'e', 'd',
' ', 'A', '.', ' ',
'S', 'h', 'a', 'w',
};
// WARNING: On some systems you may have to change the
// %ld in this code to a %u since it will use unsigned ints
printf("The size of an int: %ld\n", sizeof(int));
printf("The size of areas (int[]): %ld\n", sizeof(areas));
printf("The number of ints in areas: %ld\n",
sizeof(areas) / sizeof(int));
printf("The first area is %d, the 2nd %d.\n", areas[0], areas[1]);
printf("The size of a char: %ld\n", sizeof(char));
printf("The size of name (char[]): %ld\n", sizeof(name));
printf("The number of chars: %ld\n", sizeof(name) / sizeof(char));
printf("The size of full_name (char[]): %ld\n", sizeof(full_name));
printf("The number of chars: %ld\n",
sizeof(full_name) / sizeof(char));
printf("name=\"%s\" and full_name=\"%s\"\n", name, full_name);
return 0;
}