Strlen nie wylicza prawidłowo długości stringu. W poniższym kodzie string s ma długość 4, a printf wyświetla długość 8.
Dlaczego strlen zwraca złą wartość? Co można z tym zrobić?
#include <stdio.h>
#include <string.h>
int main(void)
{
char s[] = "ĄĘżć";
printf("%d\n", (int) strlen(s));
return 0;
}
Kompilator gcc 4.6.2