Thread: Initializing multiscripted arrays

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    204

    Initializing multiscripted arrays

    What is the correct form to initialize a multiscripted array?
    1-
    Code:
    char names[3][11] = {{"texto1.txt"}, {"texto2.txt"}, {"texto3.txt"}};
    2-
    Code:
    char names[3][11] = {"texto1.txt", "texto2.txt", "texto3.txt"};
    Thanks.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Both of those forms.
    6.7.8 Initialization

    14 An array of character type may be initialized by a character string literal, optionally enclosed in braces.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Initializing arrays in a class
    By ejohns85 in forum C++ Programming
    Replies: 2
    Last Post: 03-19-2009, 09:06 AM
  2. Replies: 23
    Last Post: 12-06-2008, 01:39 PM
  3. initializing multi-dimensional arrays
    By cyberfish in forum C++ Programming
    Replies: 4
    Last Post: 10-31-2007, 08:15 PM
  4. newbee: initializing arrays
    By breaka in forum C Programming
    Replies: 11
    Last Post: 06-12-2006, 12:20 PM
  5. Initializing dynamic arrays
    By cunnus88 in forum C++ Programming
    Replies: 9
    Last Post: 11-21-2005, 09:50 AM