Hello,
In C code below why I cannot use float to declare pointer to the floating point number. It has used “char” but I don’t understand why.
could you explain it to me?
Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
#include "stm321476xx.h"
‡include <stdio.h>unsignedint a =1;unsignedint b, c;float x =3.0;int main (){// declare pointer to the floating point number x//char*ptr =(char*)&x;
My teacher told us that we cannot use float pointer here. I am not sure, but I guess due to having “int main “command, we cannot point to the floating numbers by float pointer.
int main has nothing to do with this.
I suggest you replace the char pointer with float pointer and run the program and see what does not work.
We can help you if you have clear problem statement.