Jump to content

std::list<std::string *> List of pointer to strings problem

- - - - -

  • Please log in to reply
No replies to this topic

#1
akumafan

akumafan

    Newbie

  • Members
  • Pip
  • 1 posts
I'm trying to make it so that when I press a key on the keyboard, onChar appends the value to a string that belongs to a list. It's causing some type of error though. Please help me figure this out, if you could.

If it's a cause of confusion, m_stringlist is a std::list<std::string *> and m_stringlistiter is a std::list<std::string *>::iterator.

Thank you

void Controller::onCreate(xMessage *msg)
{
std::string *first_string;
first_string = new std::string("Welcome to this program!\n");
m_stringlist.push_back(first_string);
first_string = new std::string("... ");
m_stringlist.push_back(first_string);

m_stringlistiter = m_stringlist.begin();

}


void Controller::onChar(xMessage *msg)
{
// Create a string object
std::string buf;

// Assign the string object the value of the char entered
buf = LOWORD(msg->wparam);

// Get the current line
std::string *curline = *m_stringlistiter;

// Append the char to the current line
std::string compline = *(curline) + buf;

// Print the compline
MessageBox(msg->hwnd, compline->c_str(), "Title", MB_OK);

}




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users