"/ the starting /root dir the cd command dosn't work
// no matter what you neter with cd it allways brings
// you to the etc dir "
this is because:


else{

cout << "BASH command not found:" << endl;
goto etc;
}

whatever mistake u enter will output the message and then goto etc.i'm assuming u meant to go to rootd?

" cin >> com2;"

cin will only read up to the first blank space,therefor if the user entered:

cd etc

or

cd whatever

it will be read as 'cd' only.to solve this use the cin.getline( ) function.cin.getline read all the characters typed until it's maximum is reached or until a newline is encounterd.i'd suggest replacing every cin in ur code with cin.getline.i think that should solve the problem.i've modified a part of ur code to illustrate what i meant.







#include <iostream.h>
#include <string.h>


int main(int argc, char *argv[])
{

char com1[1024];
char com2[1024];
char comi2[1024];


// i took out the first section because it works fine

root:// start of the unix box in
cout << "/root:";

cin.getline(com1,80);

if(strcmp(com1,"help")==0){ // tells you want commands their are

cout << "commands" << endl;
cout << "cd" << endl;
cout << "ls" << endl;
goto root; // brings you back to root so you will have a prompt
}
if(strcmp(com1,"ls")==0){ // lets you give the ls command

cout << "bugreport" << endl;
cout << "landing" << endl;
cout << "watergate" << endl;
cout << "WOMDIRAQ" << endl;
goto root; // same thing as befor
}
if(strcmp(com1,"cd../")==0){ // same thing as ls
goto rootd;
}

else{

cout << "BASH command not found:" << endl; // give you an error message if you use a nonlisted command
goto root;
}

rootd: // is the root dir that /root is keeped in
cout << "/:";

cin.getline(com2,80);

if(strcmp(com2,"help")==0){ // same thing as befor
cout << "commands" << endl;
cout << "cd" << endl;
cout << "ls" << endl;
goto rootd;
}

if(strcmp(com2,"ls")==0){ // same thing give you the list of what in the file

cout << "etc" << endl;
cout << "root" << endl;
cout << "home" << endl;
goto rootd;
}

if(strcmp(com2,"cd etc")==0){ // this is wear i have a problem i think this is
goto etc; // i think this is wear at least once i move from
} // the starting /root dir the cd command dosn't work

else{

cout << "BASH command not found:" << endl;
goto rootd;
}
// no matter what you neter with cd it allways brings
etc: // you to the etc dir
cout << "/etc:";
// the varable that is used tell what command you put in
cin.getline(comi2,80); // i all so used an embedded if statmentto move up and down the dirs
if(strcmp(comi2,"ls")==0){ // this command works

cout << "passwd" << endl; // contents of etc
cout << "shadow" << endl;
goto etc;
}
if(strcmp(comi2,"cd../")==0){ // same as befor and this one works

goto rootd;
}
else{

cout << "BASH command not found:" << endl;
goto etc;
}

return 0;
}