Deitel & Deitel, C How to Program 6th Edition, Exercise 9.9 (Printing Pointer Values as Integers)
// 9.9 Printing Pointer Values as Integers
#include <stdio.h>
int main() {
int *aPtr, num;
aPtr = # //placing adress of num to aPtr
printf("%%d: %9d", aPtr); //Printing a pointer value with all integer conversion specifiers
printf("-->Prints the adress of number in decimal\n");
printf("%%i: %9i", aPtr);
printf("-->Prints the adress of number in decimal\n");
printf("%%o: %9o", aPtr);
printf("-->Prints the adress of number in octal\n");
printf("%%u: %9u", aPtr);
printf("-->Prints the adress of number in decimal\n");
printf("%%x: %9x", aPtr);
printf("-->Prints the adress of number in hexadecimal\n");
printf("%%p: %9p", aPtr);
printf("-->Prints the adress of number in hexadecimal\n");
printf("\n\n\n");
return 0;
}
#include <stdio.h>
int main() {
int *aPtr, num;
aPtr = # //placing adress of num to aPtr
printf("%%d: %9d", aPtr); //Printing a pointer value with all integer conversion specifiers
printf("-->Prints the adress of number in decimal\n");
printf("%%i: %9i", aPtr);
printf("-->Prints the adress of number in decimal\n");
printf("%%o: %9o", aPtr);
printf("-->Prints the adress of number in octal\n");
printf("%%u: %9u", aPtr);
printf("-->Prints the adress of number in decimal\n");
printf("%%x: %9x", aPtr);
printf("-->Prints the adress of number in hexadecimal\n");
printf("%%p: %9p", aPtr);
printf("-->Prints the adress of number in hexadecimal\n");
printf("\n\n\n");
return 0;
}
Comments
Post a Comment