Thread: Error that does not make sense.

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    21

    Error that does not make sense.

    I'm getting an error from comparing a character pointer and an integer.

    Heres some code.


    char *scan_array = &word[0];
    char letter;

    while(scan_array != letter) // This is the line with the error.


    I dont understand why I'm getting this error when 'letter' is a character.

  2. #2
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    But scan_array is a pointer. Perhaps you should use while (*scan_array != letter) which dereferences the pointer and uses the char (element [0] of word array).

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    32
    *scan_array or *scan_array[number] or *scan_array+number - you can access the value of that address
    scan_array - is a pointer variable

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    21
    Well, all I needed is the asterisk. Wow, I don't understand why it was giving me that error.
    But it is fixed, Thanks for the help!

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I don't understand why it was giving me that error
    A "char" is really just a differently sized integer, though I'm also surprised it bothered to tell you the specific type of pointer but not the specific type of variable.

  6. #6
    Registered User
    Join Date
    Nov 2012
    Posts
    21
    Ok, that does make sense. Haha just confusing at first.

  7. #7
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Quote Originally Posted by amzc View Post
    *scan_array or *scan_array[number] or *scan_array+number - you can access the value of that address
    Your second and third suggestion is wrong. Do you know why?

    Bye, Andreas

  8. #8
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,671
    I also hope letter is actually initialized with something sane.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Does this make any sense?
    By xniinja in forum C Programming
    Replies: 20
    Last Post: 08-05-2010, 11:07 AM
  2. A SetupDI* error that doesn't make sense.
    By WDT in forum C# Programming
    Replies: 0
    Last Post: 06-25-2009, 07:29 AM
  3. does this error make sense
    By chico1st in forum C Programming
    Replies: 6
    Last Post: 05-27-2008, 11:47 AM
  4. Can anyone make sense of this?
    By tjpanda in forum C++ Programming
    Replies: 4
    Last Post: 10-12-2007, 02:16 PM
  5. Can anyone help me make sense from this?
    By correlcj in forum C Programming
    Replies: 1
    Last Post: 07-23-2002, 07:31 PM