2D string array doesn't work

Hi...!!
I am a beginner in programming .. i am trying to store student
data as in student data of student 1 is under student one ... then student 2..
i am going to take the number of students from the user for that i need 2D array of string like so

cout<<"\t \tHow many student info do you want to enter=";
cin>>no;
string (*A)[7] = new string[no][7];
for(m=0;m<no;m++)
{
cout<<endl;
cout<<"\t \tEnter the Student name:";
cin>>A[m][0];
cout<<"\t \tEnter the Father name :";
cin>>A[m][1];
cout<<"\t \tEnter the Student ID :";
cin>>A[m][2];
cout<<"\t \tEnter the Course name:";
cin>>A[m][3];
cout<<"\t \tEnter the Phone number :";
cin>>A[m][4];
cout<<"\t \tEnter the CNIC :";
cin>>A[m][5];
cout<<"\t \tEnter the Father CNIC :";
cin>>A[m][6];
cout<<"\t \tEnter the Address :";
cin>>A[m][7];

What should i do .. need an Answer ASAP..
Last edited on
Give The Brief Explanation about your problem


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

#include<iostream>
using namespace std;

int main()
{
    string arr[2][2];

    for(int i=0;i<2;i++)
    {
        for(int j=0;j<2;j++)
        {
            cin>>arr[i][j];
        }
    }

    for(int i=0;i<2;i++)
    {
        for(int j=0;j<2;j++)
        {
            cout<<" "<<arr[i][j]<<" ";
        }
    }
    return 0;
}


Output


Hello
Hello
Hello
Hello
 Hello  Hello  Hello  Hello
Topic archived. No new replies allowed.