I'm programming in C, I know why when I start my program, the terminal show me this error, but I don't know how to fix it (I have read many question about this, but no I can't solve this problem) :
My function is :
char * String_dup(char const string[]) {
size_t size = strlen(string);
char * copy = malloc(size * copy[0]);
assert(copy != NULL);
strcpy(copy, string);
return copy;
}
it consist to duplicate my string[].
And this is my test :
void StringTest_dup(void) {
char string[] = "voiture";
assert(strcmp(string, String_dup(string)));
}
Thank you for your help.