View Single Post
  #1 (permalink)  
Old October 19th, 2006, 06:19 PM
132591 132591 is offline
Authorized User
 
Join Date: Sep 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default resizeable multi-dimensional array

what is wrong with this code?
Code:
/* program: multi dimensional array
 * description: creates a multi dimensional array, whose size the user inputs
 */

#include <iostream>
#include <string>

using namespace std;


int main(){
    int first_dimension; //legnth of first dimension
    int second_dimension; //length of second dimension

    //iterating variables
    int i;
    int j;

    //decimal point
    string point = ".";

    cout <<"What size do you want the first dimension to be." <<endl;
    cin >>first_dimension; //input length of first dimension

    cout <<"What size do you want the second dimension to be." <<endl;
    cin >>second_dimension; //inputs length of second dimension
    cout <<"---------------------------------------" <<endl;

    string multi_array[first_dimension][second_dimension];    //declares multi dimensional array

    //nested for loops to iterate through the array
    for(i = 0; i < first_dimension; i++){
        for(j = 0; j < second_dimension; j++){
            multi_array[i][j] = i + point + j ; // assigns value to the array
            cout <<multi_array[i][j] <<endl; //displays array
        }
    }

    return 0;
}
__________________
\"Judge a man by his questions, not by his answers.\"
-Voltaire
Reply With Quote