This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

why does strstr return a pointer to a signed char?

Sorry for the basic question, but why does it not return a pointer to an unsigned char? I mean, I looked in K&R but it does explain the rational (as far as I could tell...)

Thanks

Parents
  • The trouble comes with compilers that try to be (too) helpful by warning whenever you have a signed/unsigned mismatch (especially via pointers).

    So, if you've carefully defined all your text as 'unsigned', you can get loads of warnings with the string library functions...

    :-(

    Therefore I have three typedefs in my header:

    U8 - for 8-bit things that specifically need to be unsigned;

    S8 - for 8-bit things that specifically need to be signed;

    TXT - for things that are "text" and, therefore, likely to be used with the string library functions.

Reply
  • The trouble comes with compilers that try to be (too) helpful by warning whenever you have a signed/unsigned mismatch (especially via pointers).

    So, if you've carefully defined all your text as 'unsigned', you can get loads of warnings with the string library functions...

    :-(

    Therefore I have three typedefs in my header:

    U8 - for 8-bit things that specifically need to be unsigned;

    S8 - for 8-bit things that specifically need to be signed;

    TXT - for things that are "text" and, therefore, likely to be used with the string library functions.

Children