mardi 19 mai 2020

auto type for defining variables

I was trying auto type for defining variables.

I declared an array in two ways

1. using auto

auto a={10,30,20,40};

2. using int

int b[]={10,30,20,40};

Then I wrote the following code:

cout<<sizeof(a)/sizeof(int)<<" "<<sizeof(c)/sizeof(int)
OUTPUT: 2 4

Why output is different for the two cases though both the statements means the same.

Aucun commentaire:

Enregistrer un commentaire