I wrote this 2D vector code to receive user input at runtime. Please correct me where it is posting the few errors.

Hello comrades. I wanted to make a 2D table to receive user input strings. There is a part that is not doing. Kindly advise where to correct the mistake.
#include <iostream>
#include <vector>
using namespace std;


int main (){
int cols =15;
int i,j,rows;
char reader;


cout<<"How many records do you want to create ?";

cin>>rows;

std::vector< vector<string> > dynamicArray(rows, vector<string>(cols));


dynamicArray [0][0] = "LR_UNIT_NUMBER";
dynamicArray [0][1] = "NAME_OF_PROPRIETOR";
dynamicArray [0] [2] ="NATIONAL_ID_CARD_NUMBER";
dynamicArray [0] [3] = "ADDRESS_OF_PROPRIETOR";
dynamicArray [0] [3] = "PIN_NUMBER_OF_PROPRIETOR";
dynamicArray [0] [5] = "DATE_LAND_WAS_ACQUIRED";
dynamicArray [0][6] = "DATE_OF_ISSUE_OF_TITLE_DEED";
dynamicArray [0][7] = "LAND_CATEGORY";
dynamicArray [0][8] = "TYPE_OF_OWNERSHIP";
dynamicArray [0] [9] = "COUNTY_LOCATED";
dynamicArray [0] [10] = "DISTRICT_LOCATED";
dynamicArray [0] [11] = "DIVISION_LOCATED";
dynamicArray [0][12] = "LOCATION_LOCATED";
dynamicArray [0][13] = "SUBLOCATION_LOCATED";
dynamicArray [0][14] = "VILLAGE_LOCATED";

for (i=0; i<cols; i++)
cout<<dynamicArray [0][j];

for (i=1; i<rows; i++) {

for (j=0;j<cols; j++){

cout<<"Enter the land details for the said land";
cin.get(reader);
dynamicArray.push_back(reader);
}
}
for (i=1; i<rows; i++) {
for (j=0;j<cols; j++){
cout<<"You have entered this data"<<dynamicArray[i][j]<<endl;

}
cout<<"\t";
}
system ("pause");

return 0;

}











Last edited on
Please tell us what appears to be wrong with your program. You say that only one part is not working, what part?

Please use code tags when posting code!
Topic archived. No new replies allowed.