Confused... char[10][50]

This is a discussion on Confused... char[10][50] within the C++ Programming forums, part of the General Programming Boards category; Okee, if I do this: char stuff[10][50]; that makes an array of 10 arrays of 50 chars, right? but if ...

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Confused... char[10][50]

    Okee, if I do this:

    char stuff[10][50];

    that makes an array of 10 arrays of 50 chars, right? but if I remember correctly, just going "char stuff[50];" will fill stuff with random values (pleeeeease correct me if I'm wrong right here). So, by my reasoning, each of the 10 arrays will be filled with garbage. Can I just go "char stuff[10][50] = {0};"?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >but if I remember correctly, just going "char stuff[50];" will fill
    >stuff with random values (pleeeeease correct me if I'm wrong right here
    If the array is a non-static local variable then you are correct. The initial value of the array is indeterminate.

    >Can I just go "char stuff[10][50] = {0};"?
    Yes, this will fill the entire array with 0.

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

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Thanks
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Confused about Memory
    By gL_nEwB in forum C++ Programming
    Replies: 22
    Last Post: 06-20-2006, 07:32 PM
  2. Confused
    By jeev2005 in forum C Programming
    Replies: 5
    Last Post: 06-01-2006, 02:04 PM
  3. Confused
    By (TNT) in forum C# Programming
    Replies: 1
    Last Post: 11-23-2005, 03:49 PM
  4. So Now Im getting confused?!?!?
    By zergdeath1 in forum C++ Programming
    Replies: 11
    Last Post: 03-06-2004, 04:41 PM
  5. confused.. in selecting my line of deapth
    By jawwadalam in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-04-2003, 01:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21