It don't mean a thing, if you aint got that string! [message #421101] |
Sun, 28 February 2010 06:23 |
|
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma:
|
General (3 Stars) |
|
|
I have a std::string (oh noes, not std!). And I want to tell if the first character in that string is an ampersand (&).
The std::String variable is strd.
This conditional returns true always, even if the first character is not an ampersand:
So I thought I'd try this:
const char *character = (const char *)strd.at(0);
printf("%s\n",strd.c_str());
printf("%c\n",strd[0]);
printf("%c\n",character);
if(strstr(character, "~")){
The printf's print the following:
Then at the strstr it crashes (I guess because it's supposed to be comparing strings, not characters).
Can someone suggest an appropriate way to check if the first character of a std::string equal &, please?
|
|
|