0

Hey, I was working on a program that would ask you a question and you had to put an answer. Well, when I went to compare the answer the user inputs with the right answer, it always comes up wrong and I was wondering if I did these lines of coding right:

LPSTR lpString = "";
					GetDlgItemText(hwndqw2, IDC_ANSQW, lpString, 1000);
					string span = lpString;
					string span2 = rSpnV[i];
					if(span == span2)
						MessageBox(hwndqw2,"You are right!!!", "CORRECT!", MB_OK);
					else
						MessageBox(hwndqw2, "You are wrong!!!", "WRONG!", MB_OK);
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by goody11
0

You have to allocate memory for the string because GetDlgItemText() does not do that for you.

char text[255] = {0};
GetDlgItemText(hwndqw2, IDC_ANSQW, text, sizeof(text));
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.