Thread: removing first bit from the word

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

    removing first bit from the word

    Hello,

    I have a code like this :

    pstSimPOIInfo[uiI].ppcName[ucCount] = realloc(pstSimPOIInfo[uiI].ppcName[ucCount], (usLen+strlen(CountryName)+4));
    memset(pstSimPOIInfo[uiI].ppcName[ucCount], 0, (usLen+strlen(CountryName)+4));
    strncpy((char *)pstSimPOIInfo[uiI].ppcName[ucCount], CityName, strlen(CityName)) strcat(pstSimPOIInfo[uiI].ppcName[ucCount], ","); strcat(pstSimPOIInfo[uiI].ppcName[ucCount], CountryName);

    This displays:
    CityName, CountryName like below:
    ^PCERFONTAINE,^PFRANCE
    ^PFERRIE-LA-PETITE, ^PFRANCE
    ^PQUIELON, ^PFRANCE
    ^PESMES, ^PFRANCE

    I would like to remove the first bit "^P" and display it....

    How do i do it???

    Thankx
    Jazz

  2. #2
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    mystring[0];

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    the title of your thread is wrong -- you want to remove the first byte from the string (not bits).
    Code:
    printf("%s\n", &mystring[1]);
    or you could shift all bytes left
    Code:
    strcpy(mystring,&mystring[1]);
    BTW: I've never found strncpy() a very useful function when copying null-terminated strings. strcpy does exactly the same thing that you posted, and has fewer parameters. Usually that third parameter is the size of the destination buffer, not the length of the source string, to avoid buffer overflows.
    Last edited by Ancient Dragon; 11-10-2005 at 11:02 AM.

  4. #4
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    another thread I completely misread, I think my mind is going.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 01-23-2008, 04:22 AM
  2. 16 bit word
    By chico1st in forum C Programming
    Replies: 6
    Last Post: 08-09-2007, 02:55 PM
  3. bit patterns of negtive numbers?
    By chunlee in forum C Programming
    Replies: 4
    Last Post: 11-08-2004, 08:20 AM
  4. Word Count
    By simple in forum C Programming
    Replies: 12
    Last Post: 10-04-2002, 10:47 PM