Hi, I've been messing around with small codes practicing but alot of them wont work for some reason! This isnt making sense i cant find wuts wronge with this. someone point somethen out for me please.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream> //For cout
#include <cstring> //For the string functions
usingnamespace std;
int main()
{
char name [20]
cout<<"Please enter your name:";
cin.getline ( name, 50 );
if ( strcmp ( name, "George" } == 0 )
cout<<"Thats my name. Keep?\n";
else // Not equal
cout<<"You entered your name.\n";
cout<<" Your name is " << strcat ( name ) << " and it is " << strlen ( name ) << " letters long\n";
cin.get();
}
ok so with this code after i type the word it wont go to the IF line. is it suppose to be if for it see whether u typed it right or not? There are no errors with this code
[code#include <iostream>
#include <time.h>
#include <cstdlib>
#include <windows.h>
#include <cstring>
using namespace std;
void setcolor(unsigned short color) //The function that you'll use to
{ //set the colour
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hcon,color);
}
int main ()
{
char word1[8];
loop:
cout<<"Type the word 'entrance' and hit enter to continue.";
cin.getline ( word1, 8 );
cin.ignore();
if ( strcmp ( word1, "entrance" ) == 0 ) // Equal strings
cout<<"That's correct! Lets move on.\n";
cin.get();
return 0;
if ( strcmp ( word1, "entrance" ) != 0 ) // Not equal
cout<<"That is incorrect please try again.\n";
goto loop;
}[/code]