Thread: copying or concatinating string from 1st bit, leaving 0th bit

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    3

    copying or concatinating string from 1st bit, leaving 0th bit

    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?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    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.

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    3
    Sorry for thr confusion. it was bytes... and thankx.. i got the solution

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ........ed off at functions
    By Klinerr1 in forum C++ Programming
    Replies: 8
    Last Post: 07-29-2002, 09:37 PM
  2. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  3. Again Character Count, Word Count and String Search
    By client in forum C Programming
    Replies: 2
    Last Post: 05-09-2002, 11:40 AM
  4. string handling
    By lessrain in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 07:36 PM