title: Error C++ invalid types 'int[int]' for array subscript
body: <p>I have a problem with this code. I don't know why it's wrong. I have no idea how to fix it.
  I started learning C++ not long time ago, so sorry if the question is stupid.
  This is a university exercise to special mathematics, and we have a teacher who didn't explain anything.</p>
  <p>P.S. Visual Studio Code, compiler MinGW</p>
  <p>Thanks ~</p>
  <p><a href="https://i.stack.imgur.com/zXfab.png" rel="nofollow noreferrer">enter image description here</a></p>
  <pre><code>#include &lt;iomanip&gt;
  #include &lt;conio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;windows.h&gt;
  
  using namespace std;
  int **matriceAdiacenta;
  int matriceAdiacentaLungime = 0;
  int **matriceIncidenta;
  int matriceIncidentaLungime = 0,
  matriceIncidentaArcs = 0;
  int **ListAdiacentaiacenta;
  int ListAdiacentaiacentaLungime = 0;
  int meniu, tipcitireMeniu;
  int **Virfulmatrice;
  int virfmatrice=0;
  fstream citireadinFisier;
  
  void displayMtrAdiacenta()
  {
  system(&quot;cls&quot;);
  if (matriceAdiacentaLungime &lt; 1)
  cout &lt;&lt; &quot;Va rugam sa introduceti o matrice adiacenta&quot; &lt;&lt; endl;
  else
  {
  int i, j;
  cout &lt;&lt; &quot;Matricea de adiacenta:&quot; &lt;&lt; endl;
  for (i = 1; i &lt;= matriceAdiacentaLungime; i++)
  {
  for (j = 1; j &lt;= matriceAdiacentaLungime; j++)
  cout &lt;&lt; matriceAdiacenta[i][j] &lt;&lt; &quot; &quot;;
  cout &lt;&lt; endl;
  }
  }
  cout &lt;&lt; endl
  &lt;&lt; &quot;Tastati oricare buton pentru revenirea la meniu&quot;;
  getch();
  }
  void displayMatriceaIncidenta()
  {
  system(&quot;cls&quot;);
  if (matriceIncidentaLungime &lt; 1)
  cout &lt;&lt; &quot;Va rugam sa introduceti o matrice de incidenta&quot; &lt;&lt; endl;
  else
  {
  int i, j;
  cout &lt;&lt; &quot;Matricea de incidenta:&quot; &lt;&lt; endl;
  for (i = 1; i &lt;= matriceIncidentaArcs; i++)
  {
  for (j = 1; j &lt;= matriceIncidentaLungime; j++)
  cout &lt;&lt; matriceIncidenta[i][j] &lt;&lt; &quot; &quot;;
  cout &lt;&lt; endl;
  }
  }
  cout &lt;&lt; endl
  &lt;&lt; &quot;Tastati oricare buton pentru revenirea la meniu&quot;;
  getch();
  }
  void displayListAdiacentaiacenta()
  {
  system(&quot;cls&quot;);
  if (ListAdiacentaiacentaLungime &lt; 1)
  cout &lt;&lt; &quot;Va rugam sa introduceti o lista de adiacenta&quot; &lt;&lt; endl;
  else
  {
  cout &lt;&lt; &quot;Lista de adiacenta:&quot; &lt;&lt; endl;
  for (i = 0; i &lt; ListAdiacentaiacentaLungime; i++)
  {
  cout &lt;&lt; i + 1 &lt;&lt; &quot; - &quot;;
  j = 0;
  while (ListAdiacentaiacenta[i][j] != 0)
  {
  cout &lt;&lt; ListAdiacentaiacenta[i][j] &lt;&lt; &quot; &quot;;
  j++;
  }
  cout &lt;&lt; &quot;0&quot; &lt;&lt; endl;
  }
  cout &lt;&lt; endl &lt;&lt; &quot;Apasa orice pentru a merge la meniul principal&quot;;
  getch();
  }
  }
  void StergereArc(){
  int i,x,y,j,m;
  virfmatrice=0;
  matriceIncidentaArcs=0;
  return;
  for (i=0;i&lt;m;i++) {
  matriceIncidentaArcs[x][y]=matriceIncidentaArcs[x+1][y+1];
  virfmatrice[y][j]=virfmatrice[y+1][j+1];
  }
  x=x-1;
  y=y-1;
  i=i-1;
  j=j-1;
  }
  void StergereVirf(){
  int i,j,p,n;
  matriceIncidentaArcs=0;
  for (i=0;i&lt;n;i++) {
  for (j=0;j&lt;n;j++){
  matriceIncidentaArcs[j][p]=0;
  matriceIncidentaArcs[i][p]=0;
  matriceIncidentaArcs[p][j]=0;
  }
  }
  }
  void insertMatriceAdiacenta(int tip)
  {
  int i = 0,
  j = 0;
  if (tip == 1)
  {
  citireadinFisier.open(&quot;matrAd.txt&quot;, ios::in);
  citireadinFisier &gt;&gt; matriceAdiacentaLungime;
  matriceAdiacenta = new int *[matriceAdiacentaLungime + 1];
  for (i = 1; i &lt;= matriceAdiacentaLungime; i++)
  {
  matriceAdiacenta[i] = new int[matriceAdiacentaLungime];
  for (j = 1; j &lt;= matriceAdiacentaLungime; j++)
  {
  citireadinFisier &gt;&gt; matriceAdiacenta[i][j];
  }
  }
  citireadinFisier.close();
  displayMtrAdiacenta();
  }
  else
  {
  cout&lt;&lt;&quot;Lungimea: &quot;;
  cin &gt;&gt; matriceAdiacentaLungime;
  matriceAdiacenta = new int *[matriceAdiacentaLungime + 1];
  for (i = 1; i &lt;= matriceAdiacentaLungime; i++)
  {
  matriceAdiacenta[i] = new int[matriceAdiacentaLungime];
  for (j = 1; j &lt;= matriceAdiacentaLungime; j++)
  {
  cin &gt;&gt; matriceAdiacenta[i][j];
  }
  }
  displayMtrAdiacenta();
  }
  }
  void insertMatriceIncidenta(int tip)
  {
  int i = 0,
  j = 0;
  if (tip == 1)
  {
  citireadinFisier.open(&quot;matrInc.txt&quot;, ios::in);
  citireadinFisier &gt;&gt; matriceIncidentaLungime &gt;&gt; matriceIncidentaArcs;
  matriceIncidenta = new int *[matriceIncidentaArcs];
  for (i = 1; i &lt;= matriceIncidentaArcs; i++)
  {
  matriceIncidenta[i] = new int[matriceIncidentaLungime];
  for (j = 1; j &lt;= matriceIncidentaLungime; j++)
  citireadinFisier &gt;&gt; matriceIncidenta[i][j];
  }
  citireadinFisier.close();
  displayMatriceaIncidenta();
  }
  else
  {
  cout &lt;&lt; endl&lt;&lt; &quot;Apasa orice pentru a merge la meniul principal&quot;;
  getch();
  }
  }
  void insertListAdiacenta(int tip)
  {
  int i = 0,
  j = 0;
  if (tip == 1)
  {
  citireadinFisier.open(&quot;LstInc.txt&quot;, ios::in);
  citireadinFisier &gt;&gt; ListAdiacentaiacentaLungime;
  ListAdiacentaiacenta = new int *[ListAdiacentaiacentaLungime];
  while (!citireadinFisier.eof())
  {
  ListAdiacentaiacenta[i] = new int[ListAdiacentaiacentaLungime];
  j = 0;
  do
  {
  citireadinFisier &gt;&gt; ListAdiacentaiacenta[i][j];
  j++;
  }
  while (ListAdiacentaiacenta[i][j - 1] != 0);
  i++;
  }
  citireadinFisier.close();
  displayListAdiacentaiacenta();
  }
  else
  {
  cout &lt;&lt; &quot;Lungimea: &quot;;
  cin &gt;&gt; ListAdiacentaiacentaLungime;
  ListAdiacentaiacenta = new int *[ListAdiacentaiacentaLungime];
  for (i = 0; i &lt; ListAdiacentaiacentaLungime; i++)
  {
  ListAdiacentaiacenta[i] = new int[ListAdiacentaiacentaLungime];
  j = 0;
  cout &lt;&lt; i &lt;&lt; &quot; - &quot;;
  do
  {
  cin &gt;&gt; ListAdiacentaiacenta[i][j];
  if (ListAdiacentaiacenta[i][j] &lt;= ListAdiacentaiacentaLungime)
  j++;
  } while (ListAdiacentaiacenta[i][j] != 0);
  }
  citireadinFisier.close();
  }
  }
  void matriceAdiacenta_ListAdiacenta()
  {
  system(&quot;cls&quot;);
  if (matriceAdiacentaLungime == 0)
  {
  cout &lt;&lt; &quot;Va rugam sa introduceti o matrice adiacenta&quot; &lt;&lt; endl;
  }
  else
  {
  int i, j;
  for (i = 1; i &lt;= matriceAdiacentaLungime; i++)
  {
  cout &lt;&lt; i &lt;&lt; &quot; - &quot;;
  for (j = 1; j &lt;= matriceAdiacentaLungime; j++)
  {
  if (matriceAdiacenta[i][j] == 1)
  {
  cout &lt;&lt; j &lt;&lt; &quot; &quot;;
  }
  }
  cout &lt;&lt; &quot;0&quot; &lt;&lt; endl;
  }
  }
  cout &lt;&lt; endl&lt;&lt; &quot;Apasa orice pentru a merge la meniul principal&quot;;
  getch();
  }
  void matriceAdiacenta_MatriceIncident()
  {
  system(&quot;cls&quot;);
  if (matriceAdiacentaLungime == 0)
  {
  cout &lt;&lt; &quot;Va rugam sa introduceti o matrice adiacenta&quot; &lt;&lt; endl;
  }
  else
  {
  int arcs = 0, i, j, currArc = 1, **matr;
  for (i = 1; i &lt;= matriceAdiacentaLungime; i++)
  for (j = 1; j &lt;= matriceAdiacentaLungime; j++)
  if (matriceAdiacenta[i][j] == 1)
  arcs++;
  matr = new int *[arcs];
  for (i = 1; i &lt;= arcs; i++)
  {
  matr[i] = new int[matriceAdiacentaLungime];
  for (j = 1; j &lt;= matriceAdiacentaLungime; j++)
  matr[i][j] = 0;
  }
  for (i = 1; i &lt;= matriceAdiacentaLungime; i++)
  for (j = 1; j &lt;= matriceAdiacentaLungime; j++)
  if (matriceAdiacenta[i][j] == 1)
  {
  matr[currArc][i] = -1;
  matr[currArc][j] = 1;
  currArc++;
  }
  for (i = 1; i &lt;= arcs; i++)
  {
  for (j = 1; j &lt;= matriceAdiacentaLungime; j++)
  cout &lt;&lt; matr[i][j] &lt;&lt; &quot; &quot;;
  cout &lt;&lt; endl;
  }
  }
  cout &lt;&lt; endl
  &lt;&lt; &quot;Apasa orice pentru a merge la meniul principal&quot;;
  getch();
  }
  void matriceIncidenta_matriceAdiacenta()
  {
  system(&quot;cls&quot;);
  if (matriceIncidentaLungime == 0)
  {
  cout &lt;&lt; &quot;Va rugam sa introduceti o matrice de incidenta&quot; &lt;&lt; endl;
  }
  else
  {
  int **matr, matr_out, matr_in, i, j;
  matr = new int *[matriceIncidentaLungime];
  for (i = 1; i &lt;= matriceIncidentaLungime; i++)
  {
  matr[i] = new int[matriceIncidentaLungime];
  for (j = 1; j &lt;= matriceIncidentaLungime; j++)
  matr[i][j] = 0;
  }
  for (i = 1; i &lt;= matriceIncidentaArcs; i++)
  {
  for (j = 1; j &lt;= matriceIncidentaLungime; j++)
  if (matriceIncidenta[i][j] == -1)
  matr_out = j;
  else if (matriceIncidenta[i][j] == 1)
  matr_in = j;
  matr[matr_out][matr_in] = 1;
  }
  //afisare
  for (i = 1; i &lt;= matriceIncidentaLungime; i++)
  {
  for (j = 1; j &lt;= matriceIncidentaLungime; j++)
  cout &lt;&lt; matr[i][j] &lt;&lt; &quot; &quot;;
  cout &lt;&lt; endl;
  }
  }
  cout &lt;&lt; endl&lt;&lt; &quot;Apasa orice pentru a merge la meniul principal&quot;;
  getch();
  }
  void matriceIncidenta_ListAdiacenta()
  {
  system(&quot;cls&quot;);
  if (matriceIncidentaLungime == 0)
  {
  cout &lt;&lt; &quot;Va rugam sa introduceti o matrice de incidenta&quot; &lt;&lt; endl;
  }
  else
  {
  int i, j, k;
  for (j = 1; j &lt;= matriceIncidentaLungime; j++)
  {
  cout &lt;&lt; j &lt;&lt; &quot; - &quot;;
  for (i = 1; i &lt;= matriceIncidentaArcs; i++)
  if (matriceIncidenta[i][j] == -1)
  for (k = 1; k &lt;= matriceIncidentaLungime; k++)
  if (matriceIncidenta[i][k] == 1)
  {
  cout &lt;&lt; k &lt;&lt; &quot; &quot;;
  break;
  }
  cout &lt;&lt; &quot;0&quot; &lt;&lt; endl;
  }
  }
  cout &lt;&lt; endl&lt;&lt; &quot;Apasa orice pentru a merge la meniul principal&quot;;
  getch();
  }
  void ListAdiacenta_matriceIncidenta()
  {
  system(&quot;cls&quot;);
  if (ListAdiacentaiacentaLungime == 0)
  {
  cout &lt;&lt; &quot;Va rugam sa introduceti o matrice adiacenta&quot; &lt;&lt; endl;
  }
  else
  {
  int k = 0, i, j, **matr;
  for (i = 0; i &lt; ListAdiacentaiacentaLungime; i++)
  {
  j = 0;
  while (ListAdiacentaiacenta[i][j] != 0)
  {
  k++;
  j++;
  };
  }
  matr = new int *[k];
  for (i = 1; i &lt;= k; i++)
  {
  matr[i] = new int[ListAdiacentaiacentaLungime];
  for (j = 1; j &lt;= ListAdiacentaiacentaLungime; j++)
  {
  matr[i][j] = 0;
  }
  }
  k = 1;
  for (i = 0; i &lt; ListAdiacentaiacentaLungime; i++)
  {
  j = 0;
  while (ListAdiacentaiacenta[i][j] != 0)
  {
  matr[k][i + 1] = -1;
  matr[k][ListAdiacentaiacenta[i][j]] = 1;
  k++;
  j++;
  };
  }
  for (i = 1; i &lt;= k - 1; i++)
  {
  for (j = 1; j &lt;= ListAdiacentaiacentaLungime; j++)
  cout &lt;&lt; matr[i][j] &lt;&lt; &quot; &quot;;
  cout &lt;&lt; endl;
  }
  }
  cout &lt;&lt; endl&lt;&lt; &quot;Apasa orice pentru a merge la meniul principal&quot;;
  getch();
  }
  void ListAdiacenta_matriceAdiacenta()
  {
  system(&quot;cls&quot;);
  if (ListAdiacentaiacentaLungime == 0)
  {
  cout &lt;&lt; &quot;Va rugam sa introduceti o lista de adiacenta&quot; &lt;&lt; endl;
  }
  else
  {
  int **matr, i, j;
  matr = new int *[ListAdiacentaiacentaLungime];
  for (i = 1; i &lt;= ListAdiacentaiacentaLungime; i++)
  {
  matr[i] = new int[ListAdiacentaiacentaLungime];
  for (j = 1; j &lt;= ListAdiacentaiacentaLungime; j++)
  matr[i][j] = 0;
  }
  for (i = 0; i &lt; ListAdiacentaiacentaLungime; i++)
  {
  j = 0;
  while (ListAdiacentaiacenta[i][j] != 0)
  {
  matr[i + 1][ListAdiacentaiacenta[i][j]] = 1;
  j++;
  };
  }
  for (i = 1; i &lt;= ListAdiacentaiacentaLungime; i++)
  {
  for (j = 1; j &lt;= ListAdiacentaiacentaLungime; j++)
  cout &lt;&lt; matr[i][j] &lt;&lt; &quot; &quot;;
  cout &lt;&lt; endl;
  }
  }
  cout &lt;&lt; endl&lt;&lt; &quot;Apasa orice pentru a merge la meniul principal&quot;;
  getch();
  }
  int main()
  {
  bool stop = false;
  while (!stop)
  {
  cout &lt;&lt; &quot;1 - Introduceti un graf&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;2 - Afisarea grafului&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;3 - Afisati alt tip prin schimbarea celui existent&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;4 - Stergere&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;5 - Iesire&quot; &lt;&lt; endl;
  cin &gt;&gt; meniu;
  if (meniu == 1)
  {
  system(&quot;cls&quot;);
  cout &lt;&lt; &quot;1 - Matrice de adiacenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;2 - Matrice de incidenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;3 - Lista de adiacenta&quot; &lt;&lt; endl;
  cin &gt;&gt; meniu;
  system(&quot;cls&quot;);
  cout &lt;&lt; &quot;1 - Din fisier&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;2 - De la tastatura&quot; &lt;&lt; endl;
  cin &gt;&gt; tipcitireMeniu;
  if (meniu == 1)
  insertMatriceAdiacenta(tipcitireMeniu);
  else if (meniu == 2)
  insertMatriceIncidenta(tipcitireMeniu);
  else if (meniu == 3)
  insertListAdiacenta(tipcitireMeniu);
  system(&quot;cls&quot;);
  }
  else if (meniu == 2)
  {
  system(&quot;cls&quot;);
  cout &lt;&lt; &quot;1 - Matrice de adiacenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;2 - Matrice de incidenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;3 - Lista de adiacenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;next &quot;;
  cin &gt;&gt; meniu;
  if (meniu == 1)
  displayMtrAdiacenta();
  if (meniu == 2)
  displayMatriceaIncidenta();
  if (meniu == 3)
  displayListAdiacentaiacenta();
  system(&quot;cls&quot;);
  }
  else if (meniu == 3)
  {
  system(&quot;cls&quot;);
  cout &lt;&lt; &quot;1 - Matrice Adiacenta -&gt; Lista Adiacenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;2 - Matrice Adiacenta -&gt; Matrice Incidenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;3 - Matrice Incidenta -&gt; Matrice Adiacenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;4 - Matrice Incidenta -&gt; Lista Adiacenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;5 - Lista Adiacenta -&gt; Matrice Incidenta&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;6 - Lista Adiacenta -&gt; Matrice Adiacenta&quot; &lt;&lt; endl;
  cin &gt;&gt; meniu;
  switch (meniu)
  {
  case 1:
  matriceAdiacenta_ListAdiacenta();
  break;
  case 2:
  matriceAdiacenta_MatriceIncident();
  break;
  case 3:
  matriceIncidenta_matriceAdiacenta();
  break;
  case 4:
  matriceIncidenta_ListAdiacenta();
  break;
  case 5:
  ListAdiacenta_matriceIncidenta();
  break;
  case 6:
  ListAdiacenta_matriceAdiacenta();
  break;
  default:
  break;
  }
  system(&quot;cls&quot;);
  }
  else if (meniu == 4)
  {
  cout &lt;&lt; &quot;1 - Stergerea arcului&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;2 - Stergerea virfului&quot; &lt;&lt; endl;
  cin &gt;&gt; meniu;
  switch (meniu)
  {
  case 1:
  StergereArc();
  break;
  case 2:
  StergereVirf();
  break;
  default:
  break;
  }
  system(&quot;cls&quot;);}
  else
  {
  stop = true;
  }
  }
  return 0;
  }
  </code></pre>