Originally Posted by
matsp
Only if you don't compare correctly.
--
Mats
Code:
while (fgets(line,LINE_LENGTH,input)!=NULL){
command=strtok(line," \t\n\r");
if (command==NULL) continue; //empty line
if (strcmp(command,"NEW")==0){
tool=strtok(NULL," \t\n\r");
to=strtok(NULL," \t\n\r");
color=strtok(NULL," \t\n\r");
if (color==NULL || tool==NULL || to==NULL){
printMessage(output,WRONG_ARGUMENTS);
continue;
}
AddPiece(color,tool,to,output);
}//end NEW
else if (strcmp(command,"MOVE")==0){
from=strtok(NULL," \t\n\r");//from
to=strtok(NULL," \t\n\r");//to
if ((from==NULL)||(to==NULL)){
printMessage(output,WRONG_ARGUMENTS);
continue;
}
MoveTool(from,to,output);
}//end MOVE
else if(strcmp(command,"CHECKMATE")==0){
color=strtok(NULL," \t\n\r");
if (color==NULL){
printMessage(output,WRONG_ARGUMENTS);
continue; //end the current session of the loop
}
CheckCheckMate(color,dest);
}//end CHECKMATE
else if(strcmp(command,"CHECK")==0){
color=strtok(NULL," \t\n\r");
Result=CheckCheck(color,output);
if (color=NULL){
printMessage(output,WRONG_ARGUMENTS);
continue;
}
if (Result==0)//Not good Color
printMessage(output,NO_SUCH_COLOR);
if (Result==1)//CHECK
printMessage(output,CHECK);
if (Result==2 || Result==3)//NO_CHECK
printMessage(output,NO_CHECK);
}//end CHECK
else if (strcmp(command,"PRINT_BOARD")==0)
PrintBoard(output);
else if (strcmp(command,"EXIT")==0)
return;
else{
printMessage(output,WRONG_ARGUMENTS);
continue;
}
}//end While
if you can help me and take a look