Basic 2d array help :(

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
30
31
32
33
34
35
36
37
38
39
40
int main ()
{  int x=0;
   int a=0;
   int count = 0;
   char cont;
   
   ifstream infile ("Do_Not_Delete"); 
   int database [200][7];
   
   
  /////////////////////////////////////////////////
  //This is supposed to be my loop to input all the variables of the arrays
  //The first 3 columns of the array are supposed to be strings. That is why I'm using getline
  
    for (a=0;a<7;a++)
    { for(x=0;x<200;x++)
      {  if (a>0 && a<2)
         {getline(infile, database[a][x]);
         }
         else
         {infile>>database{a][x];  
         }
         }
    }
      
      
  /////////////////////////////////////////////////
  //This is going to ask the user which row he wishes to delete
  
  /*cout<<"What row do you wish to delete?"<<endl;
    cin>>rowDeleted;
    
    for(x=0;x<200;x++)
    { if (rowDelete==database[x][0])
      {  for(a=0;a<7;a++)
          {for(y=x; y<200; y++)
           database[x][a]=database[y+1][a]
           }
      }
    } */




Hi guys, so basically I'm pretty horrible at c++. I'm trying to make a 2D array that contains some strings and some ints. I want the first 3 columns to be strings and the list 4 to be ints and I'm not sure if I can do that or not. Here is my coding but there are a few errors I never solved. Oh, and I would like to have the array get filled by using the input file if I could.

The last part you don't have to worry about if you don't want to. I don't think it will work but I was trying to get it so that way if you want a row removed, the rows below it equal one row above it to kind of slide every row up one.

Can you please guide me in the right direction? Thank you very much!
2D array that contains some strings and some ints.

that's not possible, you can try making an array of structs that contain strings and numbers, or make an array of strings that is a mix of string and numbers

see:
1
2
3
4
5
int database [200][7];
// this creates an array like this
//database[0][0] = (integer value)
//...
//database[199][6] = (integer value) 
Topic archived. No new replies allowed.