CSC209H5 Lecture Notes - Lecture 2: Memory Address, Scanf Format String, Gnu Compiler Collection

116 views4 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) Write a simple c program to read in two integers separated by a space from the keyboard. Compute the sum of these two integers, then print a message back to the screen, in the format plus. /* scanf("%d %d", &num1, &num2); */ sum = num1+num2; printf( "%d plus %d equals %d\n" ,num1,num2,sum); Stack - gives a stack of memory in assembly. In the memory address, each variable will be added to the stack (in order) In the example above, num1 and num2 are both 4 bit numbers. When you say address of num1, essentially you are saying where is num1 located in your memory. To get the address of a variable, printf ( "num1"s address: %p\n" , &num1); You can also get the address of a function. printf ( "main"s address: %p\n" , &main); The address is being stored with a type and variable name and may/may not output/return something.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents