LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Use of SOH, SPACE, CR and LF in c program (https://www.linuxquestions.org/questions/programming-9/use-of-soh-space-cr-and-lf-in-c-program-399612/)

tara 01-04-2006 06:40 PM

Use of SOH, SPACE, CR and LF in c program
 
Hi

I have to compile a string and send it to an IP address.

the string needs to have this format

SOH>SOMETEXT<SPACE>SOMETEXT<CR><LF>

i have a char data[100] defined

i want to put the above string into the char data[100] i know how to put the text in using strcat, but how do i put in the SOH (0x01), Space (0x20), CR(0D)and LF(0A) around the string?


thanks
Tara

graemef 01-04-2006 07:33 PM

Hi,

you can use character escape sequences \xhh where hh is the hexadecimal number.

Code:

data[0]='\x01';
The CR and LF have their own escape sequence \r and \n and the space is just a space..

Code:

data[i]=' ';

graeme.

tara 01-05-2006 06:21 PM

Hi Graeme

thank you, works nicely

cheers
Tara :)


All times are GMT -5. The time now is 02:11 PM.