Skip to main content
deleted 4 characters in body
Source Link
Grijesh Chauhan
  • 57.8k
  • 20
  • 142
  • 213

When does memory gets allocated for a variable in c? Does it happen during declaration or initialization? Does this differ based on the scope or storage class?

Eg:

    int i; <<<<<<<< memory gets allocated here?
i=10;  <<<<<<<< memory gets allocated here?

I think, it gets allocated during declaration itself.Correct me if I am wrong.

When does memory gets allocated for a variable in c? Does it happen during declaration or initialization? Does this differ based on the scope or storage class?

Eg:

    int i; <<<<<<<< memory gets allocated here?
i=10;  <<<<<<<< memory gets allocated here?

I think, it gets allocated during declaration itself.Correct me if I am wrong.

When does memory gets allocated for a variable in c? Does it happen during declaration or initialization? Does this differ based on the scope or storage class?

Eg:

int i; <<<<<<<< memory gets allocated here?
i=10;  <<<<<<<< memory gets allocated here?

I think, it gets allocated during declaration itself.Correct me if I am wrong.

Added an example
Source Link
Karthick
  • 1k
  • 1
  • 8
  • 26

When does memory gets allocated for a variable in c? Does it happen during declaration or initialization? Does this differ based on the scope or storage class?

Eg:

    int i; <<<<<<<< memory gets allocated here?
i=10;  <<<<<<<< memory gets allocated here?

I think, it gets allocated during declaration itself.Correct me if I am wrong.

When does memory gets allocated for a variable in c? Does it happen during declaration or initialization? Does this differ based on the scope or storage class?

When does memory gets allocated for a variable in c? Does it happen during declaration or initialization? Does this differ based on the scope or storage class?

Eg:

    int i; <<<<<<<< memory gets allocated here?
i=10;  <<<<<<<< memory gets allocated here?

I think, it gets allocated during declaration itself.Correct me if I am wrong.

Source Link
Karthick
  • 1k
  • 1
  • 8
  • 26

When does memory gets allocated for a variable in c?

When does memory gets allocated for a variable in c? Does it happen during declaration or initialization? Does this differ based on the scope or storage class?