Build a program that performs the following operations:
• Declares three pointer variables called iPtr of type int,
cPtr of type char, and fFloat of type float.
• Declares three new variables called iNumber of int type,
fNumber of float type, and cCharacter of char type.
• Assigns the address of each non-pointer variable to the
matching pointer variable.
• Prints the value of each non-pointer variable.
• Prints the value of each pointer variable.
• Prints the address of each non-pointer variable.
• Prints the address of each pointer variable.
Code
#include <stdio.h>
int main()
{
int *iPtr;
char *cPtr;
float *fFloat;
int iNumber;
float fNumber;
char cCharacter;
printf("Enter an integer number: ");
scanf("%i", &iNumber);
printf("Enter a float number: ");
scanf("%f", &fNumber);
printf("Enter a character: ");
scanf("%c", &cCharacter);
iPtr = &iNumber;
fPtr = &fNumber;
cPtr = &cCharacter;
printf("iNumber=%i, fNumber=%f, cCharacter=%c\n", iNumber, fNumber, cCharacter);
printf("Pointers values: iPtr=%i, fPtr=%f, cPtr=%c\n", *iPtr, *fPtr, *cPtr);
printf("Memory address of iNumber=%p, fNumber=%p, cCharacter=%p\n", &iNumber, &fNumber, &cCharacter);
printf("iPtr points to %p, fPtr points to %p, cPtr points to %p\n", iPtr, fPtr, cPtr);
return 0;
}
problem - fPtr undeclared?
not understanding how I did my pointer wrong
p.s. sorry for indentation