Multidimensional Arrays

Discussion in 'C++' started by Victor Bazarov, Dec 13, 2003.

  1. Take a look at the FAQ. Section 16, question 16.15.
    Victor Bazarov, Dec 13, 2003
    1. Advertisements

  2. No. But my GNU C++ compiler
    g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

    will create variable-size arrays:
    #include <iostream>

    int main(int argc, char* argv[]) {
    const int m = atoi(argv[1]);
    const int n = atoi(argv[2]);
    int test[m][n];
    std::cout << "Hello World!" << std::endl;
    return 0;
    } In function `int main(int, char**)': warning: ISO C++ forbids variable-size array `test' warning: ISO C++ forbids variable-size array `test' warning: unused variable `int test[m][n]'
    Hello World!

    Variable-size arrays were recently
    introduced into the ANSI/ISO C 99 standard.
    Are they part of the ANSI/ISO C++ 2003 standard?
    E. Robert Tisdale, Dec 13, 2003
    1. Advertisements

  3. Victor Bazarov

    Jon Bell Guest

    Jon Bell, Dec 13, 2003
  4. Victor Bazarov

    Jack Klein Guest


    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    Jack Klein, Dec 13, 2003
  5. Victor Bazarov

    Ron Natalie Guest

    Ron Natalie, Dec 13, 2003
  6. Victor Bazarov

    Maximus Guest

    I'd like to know if it's possible to allocate a multidimensional array
    during runtime using the new operator. I tried but VC tells me this:

    C:\Program Files\Microsoft Visual Studio\MyProjects\asdf\asdf.cpp(9) : error
    C2440: '=' : cannot convert from 'int (*)[32]' to 'int *'
    Types pointed to are unrelated; conversion requires
    reinterpret_cast, C-style cast or function-style cast

    don't have a clue what all this mean, execpt that what I'm trying to do is
    wrong =)

    #include "stdafx.h"

    int main(int argc, char* argv[])
    int *test;
    test = new int[32][32];

    printf("Hello World!\n");
    return 0;

    Maximus, Dec 13, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.