-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathC7E2UserInputPointerVariable.c
68 lines (42 loc) · 1.73 KB
/
C7E2UserInputPointerVariable.c
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* Challanges Ch7E2 - UserInputPointerVariable */
// By Jim-Kristian Malmhaug | Date: 2 October 2013
//Notes:
//References:
#include <stdio.h>
int menuSelection(void); //Function prototype for showing the menu.
main() {
int iSelect = 0;
int iValue = 0;
int *iPtr;
while(iSelect != 5) {
system("clear");
iSelect = menuSelection();
switch(iSelect) {
case 1:
printf("\nEnter the new integer value: ");
scanf("%d", &iValue);
break;
case 2:
iPtr = &iValue;
printf("\nMessage: The address of the pointer is: %p", iPtr);
break;
case 3:
printf("\nMessage: The address of the integer value is: %p", &iValue);
break;
case 4:
printf("\nMessage: The integer value is %d.", iValue);
break;
}
}
} //End of main()-function
/***************************************************
FUNCTION DEFINITION
menuSelection()
***************************************************/
int menuSelection(void) {
int iSelect = 0;
system("clear");
printf("\n\n1. Enter New Integer Vaule\n2. Print Pointer Address\n3. Print Integer Address\n4. Print Integer Value\n5. Quit\n\n----> ");
scanf("%d", &iSelect);
return iSelect;
}