Results 1 to 2 of 2

Thread: Structures and Pointers

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    England
    Posts
    94

    Question Structures and Pointers

    Hey Guys

    I have a really weird problem.

    basically i have a structure which is made up of pointers which point to an array of structures. The pointers whithin each of these structures then points to a BYTE array on the freestore.

    My problem is when i try and copy some data out of another buffer which is also on the freestore to these buffers i end up getting loads of crap in the buffers. I end up with all sorts of **** from the memory i mean i am getting stuff thats built into the program printed liek some of my error messages that are printed by messagebox's. Any ideas would be great

    peter
    "Let's all join forces, rule with an iron hand...and prove to all the world, metal rules the land..."
    -- Judas Priest

    My email is [email protected]

  2. #2
    jim mcnamara
    Guest
    1. your BYTE arraysmay not have been initialized to '\0' as string,
    and 0 for nums. Use

    memset(&array,'\0',sizeof(array) ) -
    this initializes any integer variable to 0 and sets strings to zero-length.

    2. your pointers are aimed to outerspace. Use assert.

    3. You're taking chars --> DWORD as I recall,, so after playing around the buffers will have wierd stuff in them. Re-initalize if necessary.

    Plus, you're completely sure that your BYTE arrays have valid data in them, right? See #4

    4. if you mess with strings, string operations leave crud in memory after the trailing '\0' character, especially after several strcpy operations on the same piece of memory. File i/o's (like fgets) can leave \n at the tail of the string, too.

    And it's not a weird problem at all, especially in C.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width