first version of ex8.c
This commit is contained in:
parent
3a7ae25fa3
commit
593c551085
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ ex4
|
|||||||
ex5
|
ex5
|
||||||
ex6
|
ex6
|
||||||
ex7
|
ex7
|
||||||
|
ex8
|
||||||
|
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
|||||||
CFLAGS=-Wall -g
|
CFLAGS=-Wall -g
|
||||||
|
|
||||||
EXERCISES = ex1 ex3 ex4 ex5 ex6 ex7
|
EXERCISES = ex1 ex3 ex4 ex5 ex6 ex7 ex8
|
||||||
|
|
||||||
|
|
||||||
all: $(EXERCISES)
|
all: $(EXERCISES)
|
||||||
|
36
ex8.c
Normal file
36
ex8.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#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', '\0'
|
||||||
|
};
|
||||||
|
|
||||||
|
printf("The size of an int: %d\n", sizeof(int));
|
||||||
|
printf("The size of areas (int[]): %d\n",
|
||||||
|
sizeof(areas));
|
||||||
|
printf("The number of ints in areas: %d\n",
|
||||||
|
sizeof(areas) / sizeof(int));
|
||||||
|
printf("The first area is %d, then 2nd %d.\n",
|
||||||
|
areas[0], areas[1]);
|
||||||
|
|
||||||
|
printf("The size of char: %d\n", sizeof(char));
|
||||||
|
printf("The size of name (char[]): %d\n",
|
||||||
|
sizeof(name));
|
||||||
|
printf("The number of chars: %d\n",
|
||||||
|
sizeof(name) / sizeof(char));
|
||||||
|
|
||||||
|
printf("The size of full_name (char[]): %d\n",
|
||||||
|
sizeof(full_name));
|
||||||
|
printf("The number of chars: %d\n",
|
||||||
|
sizeof(full_name) / sizeof(char));
|
||||||
|
|
||||||
|
printf("name=\"%s\" and full_name=\"%s\"\n",
|
||||||
|
name, full_name);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user