c++ - Loop through hex variable in C -


I have the following code in a project that writes 'the representation of SCI to Packet in a unix tty:

  int written = 0; Int start_of_data = 3; // Write data to FIFO (length) {if (written (= written = FIFO_FD, and packet [start_of_data], length)) == -1) {printf ("Error writing FIFO"); } And {length - = written; }}  

I just want to take the data that is written in the socket and it is inserted into a variable. To debug, I just trying the first letter / digit printf I have tried several ways to print it, but I'm getting hex form (I think).

Expected output is: 13176 and hex value is: 31 33 31 37 36 0a (if it is also hex)

Obviously the fastest tool in my C skill shade Are not there.

Update: I'm using hexdump () to get the output

itemprop = "text">

These are characters: 31 '1', 33 is '3' etc. 0D and 0A are ending the new line characters, also known as '\ r' and '\ n' respectively. So if you convert values ​​to characters, you can print them directly, eg. With % c or % s draft code, with printf . As you can see from the linked table, the values ​​you posted represent "13176": -)


Comments