Thread: multi dimensional array at runtime

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    It is illegal because C++ requires compile-time constant values to be used for the array size when you declare a local array like you did. If you use a dynamic array (with new), then you can give it a variable size.

    Since the OP mentioned "pure c", it was not a bad suggestion, it is legal in C, but since this is a C++ forum, it just needs to be noted that it is not (yet) legal in C++ and many compilers won't allow it.

  2. #17
    Registered User
    Join Date
    May 2006
    Posts
    34
    Damn that takes that reason out of the park thanks that gave me a bit more understanding wy its illegal I guess I learend something new over something else lol.

  3. #18
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Looking beyond legality, there are many articles on the difference between runtime memory and compile-time memory. You should look into them as that information is quite essential to programming.
    Sent from my iPadŽ

  4. #19
    Registered User
    Join Date
    May 2006
    Posts
    34
    Dude Were chaning the post Stop adding offtopic their is no point I said I understood and I figured out difference long time ago gezz your old man.

  5. #20
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    I posted 2 minutes after you. If you knew the difference, you wouldn't have posted such a fundamental mistake. Get your act together before you start mouthing off, kid.

    Now, if I may. Topic Closed. *waits for Salem*
    Sent from my iPadŽ

  6. #21
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Quote Originally Posted by ChaosEngine
    I'm surprised at that, but Daved is correct. It is non-standard C++.
    Quote Originally Posted by unkownname
    Alright I get your point it just seemed to work Dont get all flamy at me. your forgetting the reason for this post
    My god, you're a bit thin-skinned aren't you? I wouldn't have thought even the most sensitive soul would take "It is non-standard C++" as a flame, but there you go. Harden up, boy.
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  7. #22
    Registered User
    Join Date
    May 2006
    Posts
    34
    Are you guys kidding me Dude Get off this topic It dosent take that long to learn something maybe you to but not to me so damn If you guys have any dignaty get off my back.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem within multi dimensional array
    By lolguy in forum C Programming
    Replies: 5
    Last Post: 12-26-2008, 08:02 AM
  2. Multi Dimensional Array Compare
    By guitarist809 in forum C++ Programming
    Replies: 11
    Last Post: 05-10-2006, 05:03 PM
  3. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  4. defining array size at runtime
    By Sanglier in forum C Programming
    Replies: 3
    Last Post: 09-16-2002, 11:38 AM
  5. 2d arrays in C
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 04-20-2002, 11:09 AM