Memory allocation in C. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Memory allocation in C.

Can anyone explain me when memory is allocated for the variable. Is it allocated during variable declaration or variable definition?

22nd Sep 2020, 5:03 AM
Samir Singh
Samir Singh - avatar
1 Answer
+ 1
When its declared. Thats why you need to specify the type. when i initialize: int n; //The program beggs for space for the integer. You can find how much memory is set aside using sizeof() on any data type
22nd Sep 2020, 7:19 AM
Slick
Slick - avatar