I have two strings, both of which are equal, and I get their lengths like this
size_t len = strlen(s1);
size_t len2 = strlen(s2);
I need to know what those are equal to, since the strings will not always be equal, so I tried printing out both values like this
printf("len1: %zu len2: %zu", len, len2);
but, this prints nothing. If I put this
printf("%s %s\n", s1, s2);
in the line above it, it prints out test string test string
, which tells me that neither string is NULL
. What is causing the string lengths to not print?
Your first printf
is missing a \n
, so the output is getting buffered (and not flushed to the console). Either add a newline to the string, or use fflush
.