Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CTasks2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
elijah vasquez
CTasks2
Commits
61630b94
Commit
61630b94
authored
Nov 01, 2022
by
elijah vasquez
🦍
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
c403ce5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
memoryaddresses
memoryaddresses
+0
-0
memoryaddresses.c
memoryaddresses.c
+9
-1
No files found.
memoryaddresses
View file @
61630b94
No preview for this file type
memoryaddresses.c
View file @
61630b94
...
@@ -6,11 +6,15 @@ int main(void) {
...
@@ -6,11 +6,15 @@ int main(void) {
int
integer1
=
1
;
int
integer1
=
1
;
short
short2
=
2
;
short
short2
=
2
;
int
integer3
=
3
;
int
integer3
=
3
;
char
char1
=
4
;
float
float1
=
3
.
14
;
printf
(
"integer1 =%d Memory address%p
\n
"
,
integer1
,
&
integer1
);
printf
(
"integer1 =%d Memory address%p
\n
"
,
integer1
,
&
integer1
);
printf
(
"short2 =%d Memory address%p
\n
"
,
short2
,
&
short2
);
printf
(
"short2 =%d Memory address%p
\n
"
,
short2
,
&
short2
);
printf
(
"integer3 =%d Memory address%p
\n
"
,
integer3
,
&
integer3
);
printf
(
"integer3 =%d Memory address%p
\n
"
,
integer3
,
&
integer3
);
printf
(
"char1 = %d Memory address%p
\n
"
,
char1
,
&
char1
);
printf
(
"float1 = %d Memory address%p
\n
"
,
float1
,
&
float1
);
// Exercise Tasks
// Exercise Tasks
// 1 Run this code and take note of the addresses. Run it again and compare the addresses.
// 1 Run this code and take note of the addresses. Run it again and compare the addresses.
...
@@ -18,6 +22,7 @@ printf("integer3 =%d Memory address%p\n",integer3,&integer3);
...
@@ -18,6 +22,7 @@ printf("integer3 =%d Memory address%p\n",integer3,&integer3);
// integer1 =1 Memory address0x7ffc617a86d0
// integer1 =1 Memory address0x7ffc617a86d0
// short2 =2 Memory address0x7ffc617a86ce
// short2 =2 Memory address0x7ffc617a86ce
// integer3 =3 Memory address0x7ffc617a86d4
// integer3 =3 Memory address0x7ffc617a86d4
// Why might they be different each time you run the code?
// Why might they be different each time you run the code?
// integer1 =1 Memory address0x7ffeb7370260
// integer1 =1 Memory address0x7ffeb7370260
...
@@ -25,8 +30,11 @@ printf("integer3 =%d Memory address%p\n",integer3,&integer3);
...
@@ -25,8 +30,11 @@ printf("integer3 =%d Memory address%p\n",integer3,&integer3);
// integer3 =3 Memory address0x7ffeb7370264
// integer3 =3 Memory address0x7ffeb7370264
// 2 Add a char and a float variable, print out the value and address as above
// 2 Add a char and a float variable, print out the value and address as above
// 3 Extend each printf to also print out the size of each variable type.
// 3 Extend each printf to also print out the size of each variable type.
// 4 Rearrange the variable declaration order and see if it has an effect on the addresses
// 4 Rearrange the variable declaration order and see if it has an effect on the addresses
// You may want to rearrange your printfs to match the order of your declarations
// You may want to rearrange your printfs to match the order of your declarations
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment