Thread: byte routine not working

  1. #1
    Registered User cppdude's Avatar
    Join Date
    Jan 2002

    byte routine not working

    ok i am making a byte routine taht searches for a particular byte in a string of bytes. All the addresses of the found bytes are stored in an array. But its not working and i cant figure out why. Please tell me what i have done wrong:

    char *cptr = strchr(bytebuffy, searchnum);
    					while(cptr != NULL)
    						int a = cptr - bytebuffy;
    						Addresses1[g_FoundCount + 1] = readbase + a;
    						cptr = strchr(bytebuffy + a, searchnum);
    when this runs the windows program just hangs and stops responding as if the while loop wont stop looping

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > int a = cptr - bytebuffy
    And if this is 0, then

    > cptr = strchr(bytebuffy + a, searchnum);
    Is going to give you the same answer as last time

    Restart your search from the character after the one you've just found.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    It would be easier to do this using the string class.

  4. #4
    Registered User
    Join Date
    May 2002
    Change this line:
    cptr = strchr(bytebuffy + a, searchnum);
    cptr = strchr(bytebuffy + a + 1, searchnum);
    Hello, everyone.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need loop to copy chunks from byte array
    By jjamjatra in forum C# Programming
    Replies: 2
    Last Post: 03-05-2009, 05:42 AM
  2. Unicode 2 byte wide characters
    By davo666 in forum C Programming
    Replies: 18
    Last Post: 02-22-2009, 05:11 AM
  3. A small Debug routine
    By bftin in forum C++ Programming
    Replies: 1
    Last Post: 09-24-2004, 06:46 AM
  4. Byte confusion!!! HELP!
    By MrDoomMaster in forum C++ Programming
    Replies: 10
    Last Post: 11-12-2003, 04:54 PM
  5. New idea on conveting byte to bits/bits to byte
    By megablue in forum C Programming
    Replies: 10
    Last Post: 10-26-2003, 01:16 AM