![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pax error on appending data to LTO3 | kwliew999 | AIX | 0 | 04-20-2008 08:01 PM |
| appending space to variable | viv1 | Shell Programming and Scripting | 5 | 02-04-2008 04:01 AM |
| Appending data into a variable | michaeltravisuk | Shell Programming and Scripting | 4 | 03-08-2007 08:45 PM |
| Convert Binary data to ascii data | krishna | UNIX for Advanced & Expert Users | 4 | 11-05-2004 01:12 PM |
| help on appending data to existing data | precious51980 | UNIX for Dummies Questions & Answers | 1 | 01-27-2001 09:56 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi ...
I am having a string in the buffer .. It is binary data it may contain space . When i try to append a space in using strcpy it is taking the inbetween \n as the end and appending space .. How to append space in the binary data in C ?? please let me know Thanks in advance, Arun. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Since it is binary data, it may contain "characters" that have any ascii value (including, possibly, 0). Don't use the strxxx functions as they use these as delimiters. You could look at the memcpy family instead.
|
|
#3
|
|||
|
|||
|
Presumably you have a buffer filled with data and you know the length. Given those two bits of information, you simply set the "length" byte to space and increment length. For example:
Code:
#include <stdio.h>
int main ( void )
{
char Buffer [1024] = "ABC\0DEF\n";
int Length = 8;
Buffer [Length++] = ' ';
fwrite (Buffer, 1, Length, stdout);
/* or
write (1, Buffer, Length);
*/
}
I hope this helps. |
|||
| Google The UNIX and Linux Forums |