Open kennytowN opened 3 years ago
No, this is invalid. When declaring the array you either declare no array size (let the compiler decide this -- assuming you've an initial value). Otherwise you have to declare the size of the array. Array indexes start at 0. To have an array with just one index, you have to declare it with 1 cell.
new arr[1];
main()
{
arr[0] = 132131;
}
The error you got already told that: error 009: invalid array size (negative, zero or out of bounds). Your code is not fully functional.
This issue has been automatically marked as stale because it has not had recent activity.
new arr[0] = {132131}; printf("arr[0] = %d", arr[0]);
This code is fully functional, despite the zero size of the array, although there is an error 009 in the compiler that describes this case: "error 009: invalid array size (negative, zero or out of bounds)"