x = malloc (y).

Which of the following statements is corr

Loading

Practice Memory Allocation – x = malloc (y).

Which of the following statements is correct.

What will be output of the following “C” code?

Loading

Practice Memory Allocation – What will be output of the following “C” code?


FUNC (int *p)
{
p = (int *)malloc(100);
printf("p:%x",p);
}

int main( )
{
int *ptr;
FUNC(ptr);
printf("Ptr:%x",ptr);
return 0;
}

What should the program below print?

			  		

Loading

Practice Memory Allocation – What should the program below print?


void myfunc(char** param){
++param;
}
int main(){
char* string = (char*)malloc(64);
strcpy(string, "hello_World");
myfunc(&string);
myfunc(&string);
printf("%s
", string);
return 0;
}

What will be the output of the program on GCC compiler?

Loading

Practice Memory Allocation –

What will be the output of the program on GCC compiler?

#include<stdio.h> 
#include<stdlib.h>
int main() {
int *p;
p = (int *)malloc(20);
printf("%d ", sizeof(p));
free(p);
return 0;
}

What will be the output of the following code on GCC compiler (64 b

Loading

Practice Memory Allocation –

What will be the output of the following code on GCC compiler (64 bit machine)?

#include<stdio.h> 
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4
int main() {
int (*p)[MAXCOL];
p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p));
printf("%d, %d ", sizeof(p), sizeof(*p));
return 0;
}

What will be the output of the program on GCC compiler?

Loading

Practice Memory Allocation –

What will be the output of the program on GCC compiler?

#include<stdio.h> 
#include<stdlib.h>
int main() {
int *p;
p = (int *)malloc(20);
printf("%d ", sizeof(p));
free(p);
return 0;
}

How many bytes will be allocated for the following code on GCC comp

Loading

Practice Memory Allocation –

How many bytes will be allocated for the following code on GCC compiler(64 bit machine)?

#include<stdio.h>  
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4
int main() {
int (*p)[MAXCOL];
p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p));
return 0;
}

The functionmalloc() returns a fl

Loading

Practice Memory Allocation –

The functionmalloc() returns a float pointer if the memory is allocated for storing float values and a double pointer if memory is allocated for storing double values.

Which of the following statements is correct?

Loading

Practice Memory Allocation –

Which of the following statements is correct?

Specify the 2 library functions to dynamically allocate memory?

Loading

Practice Memory Allocation –

Specify the 2 library functions to dynamically allocate memory?