Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aranince

macrumors 65816
Original poster
Apr 18, 2007
1,104
0
California
I'm trying to get a char from an std::string and see what it's value is. The error is on the line of the if statement. Cannot convert from `const char' to `const char*'

Code:
    const char done = taskdata.at(1);
    if(strncmp(done, "*", 1) == 0)
        m_done = true;
    else
        m_done = false;
 

iSee

macrumors 68040
Oct 25, 2004
3,540
272
strncmp is for comparing strings of characters. To compare one character to another, you can just do it directly:

Code:
if (done == '*')
  m_done = true;
else
  m_done = false;

or even just:

Code:
m_done = (done == '*');

Notice how a character literal is surrounded by single quotes (while a string literal is surrounded by double-quotes).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.