Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C code/ Floating point num

Status
Not open for further replies.

Mina2016

Junior Member level 1
Joined
Oct 23, 2022
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
94
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>
 
unsigned int a = 1;
unsigned int b, c;
float x = 3.0;
 
int main () {
// declare pointer to the  floating point number x
//
char *ptr = (char *)&x;



Thanks
 

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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top