LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-04-2006, 06:40 PM   #1
tara
Member
 
Registered: Aug 2005
Location: Australia
Distribution: Centos 7
Posts: 58

Rep: Reputation: 15
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
 
Old 01-04-2006, 07:33 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.

Last edited by graemef; 01-04-2006 at 07:34 PM.
 
Old 01-05-2006, 06:21 PM   #3
tara
Member
 
Registered: Aug 2005
Location: Australia
Distribution: Centos 7
Posts: 58

Original Poster
Rep: Reputation: 15
Hi Graeme

thank you, works nicely

cheers
Tara
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Not enough free space while installing program with wine skippy1283 Linux - Software 1 05-30-2012 12:21 PM
Calling User-space program functions from Kernel modules shivanu Programming 1 03-05-2005 02:11 PM
Best program for checking available disk space? TippyToes Linux - Software 5 11-16-2004 09:57 PM
Not enough space for root directory on a drive with 50g free space??? auoq Linux - Newbie 1 10-13-2004 12:44 PM
How to duplicate a space i.g Program Files, ? zLinuxz Linux - General 3 05-05-2002 02:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration