Results 1 to 6 of 6

Thread: loading array values directly

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: initializing array values upon declaration

    Quote Originally Posted by jamadagni
    Do I read that as "strings in C are of the nature of pointers to char-length memory spaces"?
    Yes.

    Quote Originally Posted by jamadagni
    How come you still don't need to specify the first dimension?
    It's one of those inconsistencies and in fact arrays are evil.

    Quote Originally Posted by jamadagni
    And if I declare char *namelist[] and include lots of strings should it not be mandatory that I specify the second dimension - i.e. the maximum length of strings?
    Because you declare an array of pointers, not a two dimensional array.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: initializing array values upon declaration

    Quote Originally Posted by jacek
    It's one of those inconsistencies and in fact arrays are evil.
    Isn't that because you provide the dimension of the array right in the assignment? And furthermore, is that a standard or a compiler extension to allow such a declaration and assignment statement?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: initializing array values upon declaration

    Quote Originally Posted by wysota
    is that a standard or a compiler extension to allow such a declaration and assignment statement?
    K&R use that form of assignment in their book.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.