Im trying to write some code to make it if somone enters a word (no just a letter) then it will do something else. Cant seem to figure it out.
Im trying to write some code to make it if somone enters a word (no just a letter) then it will do something else. Cant seem to figure it out.
if(! strcmp(mystring, "string #2"))
{
// char array 'mystring' == 'string #2'
// Do This
}
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
Could you please .. explain .. more ...
is that a choices.. or .. just one word... .
if this word1 then PL:APALAL
IF this is word2 then PALALALALALLA
etc....
you can use switch loop for that..
C++
The best
Code:char inputBuffer[32]; cin.getline(inputBuffer, sizeof(inputBuffer)); int length = strlen(inputBuffer); switch(length) { case 0: { // no text break; } case 1: { // only one character break; } default: { // more than one character break; } }
Quidquid latine dictum sit, altum sonatur.
Whatever is said in Latin sounds profound.
I think I know what you mean.
Would you like to contiue?
(Y/N):
If you mean like that, to see if they typed a Y or N it goes like this
Code:char ans; cout<<"(Y/N)"; cin>>ans; if(ans == 'Y' || ans == 'y'){ //then do all this } else{ // do this }
What is C++?