Recently started to do some c programming again and are currently having issues with an assignment. The following function are supposed to initialize a string by allocating memory for it, it is also the first assignment that I'm required to use Assert().
I have to write the funcion that dstring_initialize
soo that the following works:
DString str1, str2;
str1 = dstring_initialize("");
dstring_delete(&str1);
assert(str1 == NULL);
It is probbly something basic that I have messed up and this is what the function looks like currently:
DString dstring_initialize(const char* str)
{
assert(str != NULL);
char* str1;
str1 = (char*)malloc(sizeof(char));
strcpy(str1, str);
assert(str1 == str);
return str1;
}
The error message I get is that the last Assert, Assert(str1 == str)
fails and I've been trying different things but cant figure out what I've done wrong.