samedi 5 juin 2021

I tried to define a dynamically growing array using typedef and it works up to 79 index, beyond that it doesnt, can someone sort this out?

Without giving an explicit size, it works up to index 79. It prints the value 200 at index 79, but when I increase the index by 1 that is 80, it prints nothing and program terminates.

#include <iostream>
using namespace std;

typedef int list[];
int main() {
   list myList{};
   myList[79]={200};
   cout<<myList[79]; // OUTPUT: 200
   return 0;
}
#include <iostream>
using namespace std;

typedef int list[];
int main() {
   list myList{};
   myList[80]={200};
   cout<<myList[80]; // No Output and Process finished with exit code -1073741819 (0xC0000005)
   return 0;
}

Aucun commentaire:

Enregistrer un commentaire