What happens when float pointer is typecasted to char pointer?

前端 未结 6 1418
后悔当初
后悔当初 2020-12-12 04:09
int main()
{
    float f = 12.2;
    char *p1;
    p1 = (char *)&f;
    printf (\"%d\", *p1);
}

This outputs 51.

6条回答
  •  被撕碎了的回忆
    2020-12-12 04:39

    There is slight deviation to your question I am off the topic,I usually use in such cases the snpritf Example:to fisrt format and then you can play the formatted buffer.

提交回复
热议问题