I need help with a program i am writing. It takes in a line from the user and then decides wat to do. there are to many options to spesify. some of the options are:
set TARGET 453.212.556.22
This command will differ becuase the host will never be the same.
set FUNCTION create:tcp
This function will also differ becuase there are allot of things that can be created like: reverse tcp connection, vnc session, webcam session.
use NETWORK 10.0.0.2
That will be the defualt gateway, there is also going to be allot of them.
>: download "filename" "destination"
This is going to download a file from the computer to the other computer.
See my problem isnt to write these functions. The problem is i cant seem to make my "input string" into keywords so that it can choose the write action. I cant really go and type:
set TARGET 0.0.0.1
All the way up to newest ip address, that would take ages and the program would be to big.
So i need to make my program read the firs few words:
set TARGET
and then get the next word:
10.0.0.0
One might say that i am trying to make a terminal (for linux users) or a cmd (for microsoft user).
it should act just like a cmd / terminal: getting the user input. deviding it into keywords so that it can choose wat to do.
You cant tell me that microsoft's or linux's terminal has each and every ipadress + any other possible name of a program or directory in its database. They must have used keywords.
Here is my code:
NOTE: this code istn my actual code, this is just to demonstrate what i am saying:
#include <iostream>
#include <someotherheaders>
using namespace std;
int vncsession();
{
//connects to other computer using vnc
}
int downloadfile(string filnamelocation, string filenamedest)
{
// downloads a file from target to destination
}
int main()
{
string input;
cout<<">: ";
getline(cin, input);
if(line == "use FUNCTION ")
vncsession();
else if (line == "download ")
downloadfile(keyword1, keyword2);
}
So my question actually is: How am i going to make my program brake that line into keywords and then do what it must. I have tried using an enum before but it didnt work.