c - Unallocated data type in allocated struct -


say have struct definition :

typedef struct sample {     int s; }sample; 

and declare pointer variable below

sample *sample = (sample *)malloc(sizeof(sample)); 

now question is, 'int s' placed, in stack or heap? mean there dynamic memory allocation 'int s' also?

when allocate space struct via malloc, entire struct (i.e. fields contained within struct) live on heap.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -