#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char *func(char * str){
int len;
len=strlen(str)+3;
str = (char *)realloc(str,len);
return str;
}
void main(){
printf("str:%s",func("hello"));
}
The final ans prints (null),instead of printing the string: "hello". Can anyone please explain why is it so? I am unable to identify any error. Can anyone rectify the error, and help me with a working code. Please!