Using 'if' with char arrays or string objects
How do you use the if statement with char arrays or a string object? Here is the code I have now but it doesnt' seem to work and I think I've heard somewhere that you can't use 'if' with anything more than one character. If not, then what do you use?
Code:
if(hang.spaces==hang.word)
{
MessageBox(NULL, "You Won!", hang.word, MB_OK);
hang.loopvar=false;
}
Other than that, my hangman "engine" is pretty much done and when I finish learning Win32 API I'm going to port it to that. Thx 4 all your help, and this is probably my last question... I hope
!@#$!@%#(%*#%**572!@$*!@#$!@#$!@#!$%!@#$
s***....
From this code
Code:
#include<iostream>
#include<string.h>
int main()
{
string str1= " this is a string";
cout<< str1<<endl;
cout<< "let me know what happend.?"
return 0;
}
I get these errors
Code:
--------------------Configuration: Testing - Win32 Debug--------------------
Compiling...
main.cpp
c:\program files\microsoft visual studio\myprojects\testing\main.cpp(6) : error C2065: 'string' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\testing\main.cpp(6) : error C2146: syntax error : missing ';' before identifier 'str1'
c:\program files\microsoft visual studio\myprojects\testing\main.cpp(6) : error C2065: 'str1' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\testing\main.cpp(6) : error C2440: '=' : cannot convert from 'char [18]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
c:\program files\microsoft visual studio\myprojects\testing\main.cpp(7) : error C2065: 'cout' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\testing\main.cpp(7) : error C2065: 'endl' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\testing\main.cpp(7) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
c:\program files\microsoft visual studio\myprojects\testing\main.cpp(10) : error C2297: '<<' : illegal, right operand has type 'char [27]'
c:\program files\microsoft visual studio\myprojects\testing\main.cpp(10) : error C2143: syntax error : missing ';' before 'return'
Error executing cl.exe.
Testing.exe - 8 error(s), 1 warning(s)
wtf is wrong?
Then the problem from your compiler
Then the problem from the compiler itselff...
or I don't know..
it is realy confusable.//../