Charles Tritt
/
AddressOperator
Horton Example 5.5 ported to mbed/Nucleo.
main.cpp
- Committer:
- CSTritt
- Date:
- 2017-10-25
- Revision:
- 1:0e73bf50fbf3
- Parent:
- 0:8482415bf245
File content as of revision 1:0e73bf50fbf3:
/* Project: GradeAverage File: main.cpp Ported to mbed/Nucleo by: Dr. C. S. Tritt Last revised: 10/22/17 (v. 1.1) Program 5.5 Using the & operator - from Beginning C, 5th ed. Ivor Horton. */ #include "mbed.h" int main(void) { // Define some integer variables. int a = 1; int b = 2; int c = 3; // Define some floating-point variables. float d = 4.0f; float e = 5.0f; float f = 6.0f; printf("\nVariables of type int occupy %u bytes each.", sizeof(int)); printf("\nHere are the addresses of some type int variables --"); printf("\nThe address of a is: %p.\nThe address of b is: %p.", &a, &b); printf("\nThe address of c is: %p.", &c); printf("\n\nVariables of type float occupy %u bytes each.", sizeof(float)); printf("\nHere are the addresses of some type float variables --"); printf("\nThe address of d is: %p.\nThe address of e is: %p.", &d, &e); printf("\nThe address of f is: %p.", &f); printf("\n"); // Necessary to display last line. while (true) {} // Loop forever when done. }