You are here

Convert int to char | Cypress Semiconductor

Convert int to char

Summary: 2 Replies, Latest post by Aussie Susan on 04 Nov 2014 08:22 PM PST
Verified Answers: 0
Last post
Log in to post new comments.
Cassio_Lopez's picture
1 post

I need to send a binary value through ethernet, i´m using a library  2ForLife_W5100 in PSOC5LP.
My problem is that i need to convert a binary value to char to send. I´m trying to use this, but isn´t work:

itoa(exibe_AZ,total_AZ, 2);

The declaration:

    uint16 total_AZ = 0;
    uint16 total_EL = 0;
    char exibe_AZ[16];
    char exibe_EL[16];

Obs: I included stdlib.h

user_1377889's picture
9307 posts

The base you should use (last parameter in itoa) is ten(10) and not two(2)



Aussie Susan's picture
42 posts

Presumably you will be sending 4 x 8-bit values that make up the (assumed) 32-bit integer, so what is to stop you sending each 8-bit value just as it is?

Something like:

sendByte( value & 0xff);
sendByte( (value >> 8) & 0xff);
sendByte( (value >> 16) & 0xff);
sendByte( (value >> 24) & 0xff);


Log in to post new comments.