hello i'm trying to make this into a switch statment but i'm having trouble. Any help would be great!!! this is for a shell commands in C.
if(strcmp(command->comm[0], "exit") ==0) //exit
{
printf("EXITING.....\n");
break;
}
else if(strcmp(command->comm[0],"history")==0) //history
{
int i=1;
for(;i<hisSize;i++)
printf(" %s ",history[i]);
} //history end
else if(strcmp(command->comm[0],"echo")==0) //echo
{
int i=1;
for(;i<command->args;++i)
printf("%s",command->comm[i]);
} //echo end
else if(strcmp(command->comm[0],"cd")==0) //Change directory
{
if(command->args > 2 )
printf("Too many arguments for CD.\n");
else
{
if(command->args == 1)
{
cd = getenv("HOME");
if(chdir(cd))
printf("ERROR");
}
else
{
cd = command->comm[1];
if(chdir(cd))
printf("ERROR");
}
}
}//cd end