![]() |
Operator Error Causing Vector BS
I still do understand why I can never get basic crap to work! So annoying...
:
for ( unsigned int i = 0; i <= o_game->m_msgList.size( ); i++)Error :
------ Build started: Project: Delectria, Configuration: Debug Win32 ------this is dumb! EDIT: Yes i understand the msg's that will be outputing will paint over each other i haven't done the math yet |
Main changes in bold:
:
for (size_t i = 0; i < o_game->m_msgList.size(); ++i) |
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. |
thanks a ton for your help! (both of u)
|
| All times are GMT -5. The time now is 12:50 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC