Thread: string/array problem?

  1. #1
    Mr_Stuck
    Guest

    string/array problem?

    hello, i've got a problem with strings. in my program i have a loop which concatanates strings into one large string; char bigstring[100];
    when i get back to the top of the loop i need to erase all values in bigstring[] so i can replace them with new ones, butdon't know how?
    please help!

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    UK
    Posts
    170
    Set the first array element to 0.

    bigstring[0] = 0;

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Just overwrite them.

    Post your code if you want further help.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Posts
    128

    memset

    I think it is a member of mem.h

    Code:
    memset(bigstring, 0, sizeof(bigstring));
    it takes the name of your string, what you want to initialize it to and the length of the string, simple.
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

  5. #5
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Posts
    128

    Sorry

    Not mem.h, stdlib.h or memory.h

    YES IT IS I AM GOING MAD

    MEM.H
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Not mem.h, stdlib.h or memory.h
    >YES IT IS I AM GOING MAD
    >MEM.H
    No, it isn't. memset, as defined by the C++ standard, is in <cstring>.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM