I'm trying to write a message containing "alpha = abcd" to a text file using the following code:
#include <stdio.h>
#include <wchar.h>
int
main()
{
const wchar_t *a = L"abcd", *msg = L"alpha = %s\n";
FILE *f = fopen("./deleteme", "a");
fwprintf(f, msg, a);
fclose(f);
}
However, after compiling and executing the program I get this output instead:
alpha = a
Why only the first character from the const a
gets copied to output?