Hello,
If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit.
How do i do it?
Hello,
If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit.
How do i do it?
I'll assume by 'bit' you actually mean letter? Simple pointer math will do this for you. Look up your standard string functions, such as strcat and strcpy, and simply replace the needed argument with a mystring + N, where N is the number of characters you're skipping.
Quzah.
Hope is the first step on the road to disappointment.
If you really mean bits and not bytes, then assuming you have 8-bit bytes (not all operating systems do), and say you have a string of 2 bytes. shift all bits in byte #0 left one bit, then shift all bits in byte #2 left 1 bit, and the bit shifted out of byte #1 will be shifted into the "hole" in byte #0. That will leave an unused bit in byte #1. What do you intend to put there (I think the default is 0 with left shifts)? That process will probably render the source string (the string that has the bits shifted) unusable for most string functions, such as strcat() because the string now contains binary data not text. So concantination will probably need to be done using memcpy() or some other similar function that does not care about null-terminated strings.
Last edited by Ancient Dragon; 11-10-2005 at 10:50 AM.
Sorry for thr confusion. it was bytes... and thankx.. i got the solution