Which header file should be included in c program to use malloc(), calloc(), realloc() and free()?
The pointer type returned by calloc and malloc after successful memory allocation is void pointer (*void)
What is the output of following c program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
char* p;
char* get();
p = get();
printf("%s",p);
return 0;
}
char* get()
{
char str[20] = {'a','b'};
return str;
}
malloc() returns a int pointer if memory is allocated for storing integer's and a double pointer if memory is allocated for storing double's.
What is the output of following c program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
char* p;
char* get();
p = get();
printf("%s",p);
return 0;
}
char* get()
{
char *str = malloc(20*sizeof(char));
str = "AB";
return str;
}