Discussion:
compilation warning, signed/unsigned mismatch
(too old to reply)
Hammad Imad
2004-01-20 15:45:31 UTC
Permalink
i keep getting the same compilation warning

the statement i have is

for (i=0; i < strlen(word); i++)

and the warning is

warning C4018: '<': signed/unsigned mismatch

if someone knows how to fix this please let me know,
thank you
Alexander Smith
2004-01-20 16:57:22 UTC
Permalink
Hello,

The return type of strlen() is 'size_t', which is defined on most
platforms to be something like 'unsigned long'. In any case, it's an
unsigned value. But your 'i' is a signed integer, which is why you are
getting the warning. You can remove the warning by casting the return
value to an int like this:

for (i=0; i < (int)strlen(word); i++)

Alexander
Post by Hammad Imad
i keep getting the same compilation warning
the statement i have is
for (i=0; i < strlen(word); i++)
and the warning is
warning C4018: '<': signed/unsigned mismatch
if someone knows how to fix this please let me know,
thank you
Loading...