-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path013_ExploringVariables.c
More file actions
43 lines (33 loc) · 944 Bytes
/
013_ExploringVariables.c
File metadata and controls
43 lines (33 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
int main()
{
/** The size of diffrent types of variables **/
char a;
short b;
int c;
long d;
float e;
double f;
printf("An char variable occupies %lu bytes of storage\n", sizeof(a));
printf("An short variable occupies %lu bytes of storage\n", sizeof(b));
printf("An int variable occupies %lu bytes of storage\n", sizeof(c));
printf("An long variable occupies %lu bytes of storage\n", sizeof(d));
printf("An float variable occupies %lu bytes of storage\n", sizeof(e));
printf("An double variable occupies %lu bytes of storage\n", sizeof(f));
struct stuff
{
int a;
float b;
char c[32];
};
printf("The structure 'stuff' occupies %lu bytes of storage\n", sizeof(struct stuff));
/** Memory locations of variables **/
int aa;
char bb;
float cc;
puts("\nMemory locations:");
printf("AA is at %p\n", &aa);
printf("BB is at %p\n", &bb);
printf("CC is at %p\n", &cc);
return(0);
}