Hola amigos!
Here's my current code:
Code:
/*
Wrapper around the microsoft terminal.
Useful for when shell work is not available or disabled.
*/
// Includes start here...
#include <windows.h>
#include <stdlib.h>
#include <iostream>
#include <string>
// Includes end here...
// Tell that were gonna use some namespaces here...
using namespace std;
int main()
{
bool quit = false;
string cwd = "> ";
string quitstr1 = "quit";
string quitstr2 = "Quit";
string gettext;
// Lets get the user name for nice display at the start of each line...
char currentuser[50];
DWORD ncurrentuser = sizeof(currentuser);
GetUserName(currentuser, &ncurrentuser);
while(quit == false)
{
gettext = "";
cout << currentuser << cwd;
cin >> gettext;
cin.ignore();
if(gettext == quitstr1 || gettext == quitstr2)
{
quit = true;
break;
}
// Check for 'CD...', give a string containing first two letters...
string cdstring = gettext.substr(0,2);
// Conditional strings to check for 'CD', 'Cd', 'cD', 'cd',...
string cd1 = "CD";
string cd2 = "Cd";
string cd3 = "cD";
string cd4 = "cd";
// Store current directory in this string. ABSOLUTE DEFINITIVE DIRECTORY HOLDER!
string currentdirectory = "";
if(cdstring == cd1 || cdstring == cd2 || cdstring == cd3 || cdstring == cd4)
{
string tempdirectory = gettext.substr(3,65);
currentdirectory = tempdirectory;
tempdirectory.erase(0,tempdirectory.length());
}
system(gettext.c_str());
}
return 0;
}
Seems though that when I type in at my 'shell': cd <whateverhere>, I just get an unexpected error, reported when running through C::B as:
This application has requested the Runtime to terminate it in an unusual way. Please contact the applications support team for more information.
Running it standalone though just gives me the result of the program instantaneously closing.
Any thoughts on this one?
FlyingIsFun1217