Xref: utzoo comp.lang.c:35051 comp.lang.c++:11006 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!veritas!amdcad!mozart.amd.com!proton!tim From: tim@proton.amd.com (Tim Olson) Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: Pointer arithmetic Message-ID: <1991Jan5.221508.29232@mozart.amd.com> Date: 5 Jan 91 22:15:08 GMT References: <1991Jan5.001607.5915@demott.com> Sender: usenet@mozart.amd.com (Usenet News) Reply-To: tim@amd.com (Tim Olson) Organization: Advanced Micro Devices, Austin, TX Lines: 29 In article <1991Jan5.001607.5915@demott.com> kdq@demott.COM (Kevin D. Quitt) writes: | The actual code is: | | | const unsigned char *chars = "some string" | unsigned char pass[]; | | c = strchr( chars, toupper( pass[ i ]) ) - chars + 1; | | | gcc would not accept this no matter what I did. The problem is the "unsigned" type specifier in the declaration for chars. Section 3.5.4.1 (Pointer declarators) states that For two pointer types to be compatible, both shall be identically qualified and both shall be pointers to compatible types. The function "strchr" is defined to return a type "char *"; it is not compatible with "chars", which is of type "unsigned char *". Try removing the "unsigned" specifier from the declaration for "chars", or explicitly cast the result of the strchr() function to (unsigned char *). -- -- Tim Olson Advanced Micro Devices (tim@amd.com)