View Single Post
Old Jul 1st, 2006, 10:06 PM   #3
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
You haven't given enough information. I'm guessing m_msgList is an array (or maybe a container, such as a std::vector) of std::strings.

A few hints that might help (with this error, and other issues)

1) TextOut() in the win32 API expects to receive a C-style string (an array of char delimited by a zero byte) as it's fourth argument, not a std::string. If o_game->m_msgList[i] is a std::string, it needs to be converted to a C-style string. For example; o_game->m_msgList[i].c_str().

2) The 5th argument passed to TextOut() is the length of the string. The sizeof operator does not produce the length of a string (except in some special cases, but yours isn't one of them). If we assume (again) that o_game->m_msgList[i] is a std::string, one way of computing the length of the string is o_game->m_msgList[i].length().

3) If your loop is intended to work on all elements of the array, it will work from zero to o_game->m_msgListsize()-1. Your termination clause i <= o_game->m_msgList.size() does not achieve that; it needs to be changed to i < o_game->m_msgList.size()

You will usually find things easier if you put some effort into understanding what is going on before you write your code, rather than just throwing poorly thought-out code at the compiler and wondering why it complains.
grumpy is offline   Reply With Quote