Code:
#include <iostream>
#include <string>
#include <windows.h>
#define PORT 3490 // the port client will be connecting to
#define MAXDATASIZE 100 // max number of bytes we can get at once
using namespace std;
int zoneaddr(){
return 0;
}
int info(){
return 0;
}
int access(){
}
int file(){
}
int main(int argc, char *argv[])
{
cout<<"This program is made by MaXoRaToR!\nEnter the correct password:\n";
char pow[200];
char now[200];
int bow=0;
cin.getline ( pow, 200, '\n' );
if ( strcmp ( pow, "thepassword" ) == 0 ){
cout<<"Welcome! To see, what this program offers, use info command.\n";
while(strcmp ( now, "end" ) != 0){
if(bow=1){
}
cin.getline(now,200,'\n');
if (strcmp(now,"zone") == 0){
zoneaddr();
}
else if(strcmp(now,"info") == 0){
info();
}
else if(strcmp(now,"access") ==0){
access();
}
else if(strcmp(now,"file") ==0){
file();
}
else if(strcmp(now,"end") != 0 ){
cout<<"Maxorator does not know a command named "<< now <<"\n";
}
if( strcmp ( now, "end" ) == 0 ){
cout<<"Bye-bye!";
Sleep(1000);
}
else{
cin.get();
}
bow=1;
}}
else{
cout<<"Sorry, wrong password!";
Sleep(1000);
}
return EXIT_SUCCESS;
}
Now when I enter a command right after logging in, it gets it correctly, after that it doesnt count the first char. Test it... I removed the function content, because they were long and contained only cout and sleep.