Originally Posted by
major_small
follow the standards and we can help you better... you need the <cstring> header for strcmpi, or in the older standards, <string.h>...
Well using the standard and strcmpi don't go together as the function is non standard.
Again I'll refer you to my posting using std::string instead of a character array. It won't do insenstive comparison but with a little work it can.
Edit: Just noticed one small mistake on the code in the std::string post but I can't edit that post. Should be
Code:
system(command.c_str());
My apologies for that mistake
However if you are dead set on using a null terminated array of characters here is some advise:
Using a loop to keep things alive while the person is executing commands. If you wish to use functions to get the input use return values to determine if you should continue or not.
As to why your program fails:
Code:
#include <iostream.h>
New standard specifies that the header should be <iostream>
Code:
char command[99999];
Not invalid just not good practice to use global variables
Code:
void exec();
void call();
These are ok and act as a prototype for the functions
Still ok
And here we have a problem. You think this is a call but guess what? It isn't. Its acting as a prototype for exec. to make it a call just use exec();
Code:
}
void exec()
{
cout << "Command>";
cin.getline(command, 99999, '\n');
This is ok
Code:
if(command = "quit")
Here you are trying to assign the const array of characters "quit" to the array command which isn't valid
This is ok
Same as above, its a prototype not a call
Code:
}
}
void call()
{
system(command);
This is ok
Again a prototype not a call
This is ok