I am using memcpy in my program and used it as its syntax. But the function crashes. I read some post here and tried to initialize both my char arrays but I am not getting the problem here . Can anyone please look in it?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
int i;
char *str_result;
char *str_dst = NULL;
str_result = (char *) malloc(100);
str_dst = (char *) malloc(100);
str_result = "Action done";
size_t len = strlen(str_result);
printf("string length is = %d\n", len);
memcpy(str_dst, str_result, len);
str_dst [len] = '\0';
for (i = 0; i < len; i++) {
printf("%s\n", str_dst[i]);
}
free(str_dst);
free(str_result);
return 0;
}