2d array

Hi i want to create a 2d array using a fuction.. the user will enter the dimensions(x,y) and the function will print it.. in the first row must appear the numbers 1,2,3...x and in the first column the caracters a,b,c,d,e....y(y is given as a number).. for example if the user enters x=5 y=7 it wii print:

1
2
3
4
5
6
7
8
      1 2 3 4 5 
    a _ _ _ _ _
    b _ _ _ _ _
    c _ _ _ _ _
    d _ _ _ _ _
    f _ _ _ _ _
    h _ _ _ _ _
    i _ _ _ _ _

i wrote some code but i dont knoe how to do this with the letters..

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
27
28
29
 void function(int x,int y)
    { 
        char th[x][y];
    
        for (int i = 1; i < x; i++)
        { 
           for (int j = 1; j < y; j++)
           {
              if(i==1 )
              {
                for (int k = 1; k < x; k++)
                {
                   th[i][j]=k;
                }
              }
              else if(j==1)
              {
                th[i][j]='a';
              }
              else
              {
                th[i][j]='_';
              }
              std:: cout << th[i][j] <<'\t';
           }
   
           cout << std::endl;
        }  
     } 


I'm new in c++...Thanks in advance for your help..
Topic archived. No new replies allowed.