57 lines
1.6 KiB
C
57 lines
1.6 KiB
C
#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]);
|
|
areas[0] = 100;
|
|
areas[2] = areas[1];
|
|
printf("Now the first area is %d and the 3rd area is %d.\n",
|
|
areas[0], areas[2]);
|
|
|
|
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);
|
|
|
|
printf("name[0] is %c.\n", name[0]);
|
|
printf("full_name[7] is %c.\n", full_name[7]);
|
|
|
|
name[0] = 'X';
|
|
printf("Now name[0] is %c.\n", name[0]);
|
|
|
|
full_name[7] = 'T';
|
|
printf("Now full_name[7] is %c.\n", full_name[7]);
|
|
|
|
printf("name=\"%s\" and full_name=\"%s\"\n",
|
|
name, full_name);
|
|
|
|
areas[2] = name[0];
|
|
printf("First area is now name[0]: %%c=%c, %%d=%d.\n",
|
|
areas[2], areas[2]);
|
|
|
|
return 0;
|
|
}
|