Hi,I'm writing a shell in c++ for Unix/Linux,which takes any system command
and execute it.
It's pretty simple now.In the first step,I just want to type certain command
and display it,like this:
#include <iostream>
using namespace std;
struct command_t{
char* name;
int argc;
char *argv[];
};
int main()
{
struct *command_t command;
while(true){
cout<<"$";
cin>>command->argv[0]>>command->argv[1]>>command->argv[2];
cout<<command->argv[0]<<command->argv[1]<<command->argv[2];
}
return 0;
}
However,whenever I execute it in Linux,it keeps showing
segmentation fault
if I just execute cout<<"$";
it is fine.
Thanks for any help or explanation.
and execute it.
It's pretty simple now.In the first step,I just want to type certain command
and display it,like this:
#include <iostream>
using namespace std;
struct command_t{
char* name;
int argc;
char *argv[];
};
int main()
{
struct *command_t command;
while(true){
cout<<"$";
cin>>command->argv[0]>>command->argv[1]>>command->argv[2];
cout<<command->argv[0]<<command->argv[1]<<command->argv[2];
}
return 0;
}
However,whenever I execute it in Linux,it keeps showing
segmentation fault
if I just execute cout<<"$";
it is fine.
Thanks for any help or explanation.