/* This program shows how the same pointer can point to different data variables in different statements. */
#
include < stdio.h >
int main(void) {
// Local Declarations
int a;
int b;
int c;
int * pMult;
// Statements
printf("Enter three numbers and key return: ");
scanf("%d %d %d", & a, & b, & c);
pMult = & a;
printf("%3d\n", * pMult);
pMult = & b;
printf("%3d\n", * pMult);
pMult = & c;
printf("%3d\n", * pMult);
return 0;
} // main
/* Results
Enter three numbers and key return: 10 20 30
10
20
30
*/
#
include < stdio.h >
int main(void) {
// Local Declarations
int a;
int b;
int c;
int * pMult;
// Statements
printf("Enter three numbers and key return: ");
scanf("%d %d %d", & a, & b, & c);
pMult = & a;
printf("%3d\n", * pMult);
pMult = & b;
printf("%3d\n", * pMult);
pMult = & c;
printf("%3d\n", * pMult);
return 0;
} // main
/* Results
Enter three numbers and key return: 10 20 30
10
20
30
*/
No comments:
Post a Comment