Segfault while using wcslen in C

215 views Asked by At

In C, I get a segfault while doing

const wchar_t *id = L"{{content}}\0";
wprintf(L"%s\n", wcslen(id));

I don't understand what's wrong here... Can someone enlighten me?

1

There are 1 answers

1
0___________ On BEST ANSWER

You dereference the pointer converted from size_t, and wprintf expects the pointer for the %s . Use %zu to display the length.