'Error Using pointers to get memory address locations
I have since figured this out. Thank you...I'm new to C and having trouble getting the memory address of the variable that's assigned to the pointer.
What am I missing or not understanding here. The valueVariable needs to be declared. The pointerVariable needs to be declared and set to the &valueVariable. still unsure what %x does to be honest. TIA
int main () {
double innerD, outerD, density, thickness;
double *innerDPointer, *outerDPointer, *thicknessPointer, *densityPointer;
innerD = 0.0;
outerD = 0.0;
density = 0.0;
thickness = 0.0;
innerDPointer = &innerD;
outerDPointer = &outerD;
densityPointer = &density;
thicknessPointer = &thickness;
int quantity;
int *quantityPointer;
quantityPointer = &quantity;
printf("\nAddress of innerD variable: %x\n", &innerD);
printf("\nAddress of outerD variable: %x\n", &outerD);
printf("\nAddress of density variable: %x\n", &density);
printf("\nAddress of thickness variable: %x\n", &thickness);
printf("\nAddress of quantity variable: %x\n", &quantity);
return 0;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
