Ok, well this is really aggrivating me. Im making a simple Command Prompt programs, where I enter commands, and it does them, but it doesn't work at all. It just doesn't recognize anything I give it. Whatever I put in it just spits it back out with "Unknown command". WHY??.
Also, can anyone give me feedback on if my code looks organized, and at the var name's look good. Im trying to make my code more "proffessional" looking.
Thanks!
main.cpp
Code:
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include "textf.h"
//#include "main.h"
CTextFunc CTextC;
int main()
{
CTextC.init();
return 0;
}
textf.cpp
Code:
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include "textf.h"
using std::cout;
using std::cin;
using std::endl;
void CTextFunc::init()
{
//Assign <<: to harrow before its used
charArrows = "<< : ";
startUp();
}
void CTextFunc::startUp()
{
system ("cls");
ban("Blade Tools By: Jonathan Bastnagel");
getInput();
}
void CTextFunc::getInput()
{
char charInput[256];
ba("");
cin.getline(charInput,256);
exec(charInput);
}
void CTextFunc::exec(char* charString)
{
if(charString=="")
{
ba("Nothing executed");
bn(charString);
getInput();
} else
if(charString=="q"){
system("clear");
getInput();
} else {
ba("Unknown command \'");
b(charString);
bn("\'");
getInput();
}
/*
//SWITCH DOESN'T TAKE CHAR* UGH!
switch(textString){
default: ba("Unknown command \'");b(textString);bn("\'");
}
*/
}
void CTextFunc::ban(char* charString)
{
cout<<charArrows<<charString<<endl;
}
void CTextFunc::bn(char* charString)
{
cout<<charString<<endl;
}
void CTextFunc::ba(char* charString)
{
cout<<charArrows<<charString;
}
void CTextFunc::b(char* charString)
{
cout<<charString;
}
textf.h
Code:
#ifndef TEXTF_H
#define TEXTF_H
class CTextFunc
{
public:
//Assigns default values to variables
void init();
//Starts up, shows about info
void startUp();
//Grabs keyboard input, send's to exec to be checked, and executed
void getInput();
//Checks inputed characters, and does required functions
void exec(char* charString);
//Outputs text with charArrows and new line
void ban(char* charString);
//Outputs text with charArrows
void ba(char* charString);
//Outputs text with new line
void bn(char* charString);
//Outputs text
void b(char* charString);
private:
char* charArrows;
};
#endif