Thread: Sizing Memory Q.

  1. #1
    Registered User penney's Avatar
    Join Date
    Jan 2003
    Posts
    47

    Sizing Memory Q.

    Suppose I declare a variable as:

    char Str[100];

    Does it make any difference which of the following I use for initializing the array?

    memset(Str, 0, sizeof(Str));

    vs.

    memset(Str, 0, sizeof(char * 100));

    I have been using method number 1 a lot lately and didn't know if there was some down side that I'm just not aware of.

  2. #2
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    The first is better for an array.
    p.s. What the alphabet would look like without q and r.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>char Str[100];
    >>for initializing the array
    Also:
    char str[100] = {0};
    will initialise it all to 0
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. available memory from task manager
    By George2 in forum Tech Board
    Replies: 10
    Last Post: 01-18-2008, 02:32 AM
  2. Replies: 4
    Last Post: 01-13-2008, 02:14 AM
  3. Question regarding Memory Leak
    By clegs in forum C++ Programming
    Replies: 29
    Last Post: 12-07-2007, 01:57 AM
  4. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  5. Shared Memory - shmget questions
    By hendler in forum C Programming
    Replies: 1
    Last Post: 11-29-2005, 02:15 AM