Bern, Switzerland
Offline
Jr. Member
Karma: 2
Posts: 53
|
 |
« on: October 18, 2010, 03:12:19 pm » |
Hi I have a problem to with comparing two characters. When I compare a char which is read from gps, with my char A, the solution of this compair is evertime false. If the char red from gps is really A, the compare is still false..... How can I find out if there is a A in ((char*)GPS.arguments[2])? if (((char*)GPS.arguments[2]) == "A")
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19368
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: October 18, 2010, 03:17:08 pm » |
"A" is a string. 'A' is a character.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Bern, Switzerland
Offline
Jr. Member
Karma: 2
Posts: 53
|
 |
« Reply #2 on: October 18, 2010, 03:25:29 pm » |
The corrected code throws an error: ISO C++ forbids comparison between pointer and integer if (((char*)GPS.arguments[2]) == 'A') How must I write it?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19368
I don't think you connected the grounds, Dave.
|
 |
« Reply #3 on: October 18, 2010, 03:32:15 pm » |
"char*" is a pointer, so
if (GPS.arguments[2] == 'A')
should do the trick.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Bern, Switzerland
Offline
Jr. Member
Karma: 2
Posts: 53
|
 |
« Reply #4 on: October 18, 2010, 03:36:23 pm » |
Error message is still the same....
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19368
I don't think you connected the grounds, Dave.
|
 |
« Reply #5 on: October 18, 2010, 03:38:05 pm » |
Well, if you actually told us what a "GPS" looked like, we could dispense with the banter.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Bern, Switzerland
Offline
Jr. Member
Karma: 2
Posts: 53
|
 |
« Reply #6 on: October 18, 2010, 03:42:04 pm » |
Perhaps I found a possibility with this code: char* A = {"A"}; if ((char*)GPS.arguments[2] == (char*)A[0]) But I have to go outdoor and wait until gps is set up (A is only printed if data is valid). It's cold outdoor, but I have to try it :-)
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19368
I don't think you connected the grounds, Dave.
|
 |
« Reply #7 on: October 18, 2010, 03:43:03 pm » |
Well, if you actually told us what a "GPS" looked like, we could dispense with the banter, and you don't have to suffer any discomfort.
|
|
|
|
« Last Edit: October 18, 2010, 03:43:44 pm by AWOL »
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Bern, Switzerland
Offline
Jr. Member
Karma: 2
Posts: 53
|
 |
« Reply #8 on: October 18, 2010, 03:46:53 pm » |
It's a libelium gps module ...brrrr
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19368
I don't think you connected the grounds, Dave.
|
 |
« Reply #9 on: October 18, 2010, 03:48:27 pm » |
Not the module, the variable. > 
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Bern, Switzerland
Offline
Jr. Member
Karma: 2
Posts: 53
|
 |
« Reply #10 on: October 18, 2010, 04:05:29 pm » |
Sorry, I don't know what you are asking (my english isn't good enough).
The variable who the gps is writing in the array can be a A or a V. When the pointer shows on position 2 in the array like: GPS.arguments[2], it should return the character A or V....
So I thought that I can compare this character with another char.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19368
I don't think you connected the grounds, Dave.
|
 |
« Reply #11 on: October 18, 2010, 04:17:03 pm » |
Show us the C declaration of the "GPS" variable (as in "GPS.arguments[2]") from your sketch, my psychic powers are failing. Please.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
|