Dynamic array in Stack ?

This is a discussion on Dynamic array in Stack ? within the C++ Programming forums, part of the General Programming Boards category; Is this a correct ? This is compiled with g++ (3.4) sucessfully. Code: int main() { int x = 12; ...

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    1

    Question Dynamic array in Stack ?

    Is this a correct ?
    This is compiled with g++ (3.4) sucessfully.

    Code:
    int main()
    {
        int x = 12;
        char pz[x]; 
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,981
    Quote Originally Posted by janaka
    Is this a correct ?
    This is compiled with g++ (3.4) sucessfully.
    If your aim is to write standard C++, then no, that is not correct. If your aim is to use g++'s variable length array compiler extension for g++, then yes, that is correct.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++11 User Tux0r's Avatar
    Join Date
    Nov 2008
    Location
    Sweden
    Posts
    135
    And if your intention was to write C99 code then it is valid. Otherwise use std::vector<char>.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic stack?
    By vikernes in forum C++ Programming
    Replies: 6
    Last Post: 06-19-2007, 01:31 PM
  2. Finished Stack
    By the pooper in forum C Programming
    Replies: 11
    Last Post: 02-02-2005, 09:52 AM
  3. 2D array in dynamic memory
    By VanJay011379 in forum C++ Programming
    Replies: 3
    Last Post: 03-16-2003, 07:34 PM
  4. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM
  5. Array Stack Problem
    By Drew in forum C++ Programming
    Replies: 3
    Last Post: 09-04-2001, 06:58 PM

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