Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Cannot compare pointers to strings?

  1. Sep 6, 2009 #1
    After compiling the code below, GCC says that you can't compare a pointer to string by iso C++ standards.

    But I don't see a pointer anywhere (I don't know pointers for now...did it long ago, now forgot)...may be it has to do with the fact that arrays are called by reference.

    Code (Text):
    char convert(unsigned char input[]);
        unsigned char input[1000];
    char convert (unsigned char input[])
        int i;
        if(input[0] == " ");
  2. jcsd
  3. Sep 6, 2009 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    input[0] has type unsigned char&.
    " " has type const char*.

    You meant ' ' which has type char.
  4. Sep 7, 2009 #3
    Oh...damn...I meant single quotes. :P
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Cannot compare pointers to strings?
  1. This pointer (Replies: 2)

  2. Pointers and classes (Replies: 1)

  3. Use of pointers (Replies: 3)

  4. Pointers and strings (Replies: 19)