Hi! I have this:
char authToken[] = "token";
char *authHeader = malloc(
(strlen("Authorization: Bearer ") + strlen(authToken)) * sizeof(char));
// authHeader = '\0'; // if I uncomment this, the output will be as expected: Authorization: Bearer token
strcat(authHeader, "Authorization: Bearer ");
strcat(authHeader, authToken);
printf("%s\n", authHeader);
free(authHeader);
If I don't uncomment the given line, then the output looks something like this: r�j[�UAuthorization: Bearer token
Why is this? Am I doing something wrong with malloc? Also, am I doing anything unnecessary here? I feel like I am, but I'm really not quite sure.