Initializing array below is same as initializing variables in cpp language

#include<iostream>
using namespace std;
int main(){
    int a[0];
    cin>>a[0];
    cout<<a[0];
}

if i donot take input it prints garbage value? why compiler do not throw error on declaring array having size zero?



Read more here: https://stackoverflow.com/questions/65715106/initializing-array-below-is-same-as-initializing-variables-in-cpp-language

Content Attribution

This content was originally published by Muneeb Aslam at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: