Picani
Picani

Reputation: 179

Segfault while using wcslen in C

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?

Upvotes: 0

Views: 212

Answers (1)

0___________
0___________

Reputation: 67835

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

Upvotes: 3

Related Questions