I am writing a game. The game will be controlled by the cmd, it is like a hacking game. You type: run exploit545.exploit www.tktktk.switchnet and it will exploit that exploit at the targeted computer (url). My problem is i cant seem to find a way to make the program read only the first words and then detirman what it should do, then read the other words and detriman to who it should do it. So bassicly i need to make a program that will read the line the user enters, then put each word, either in a array or into a new string so that it can determan what to do better (Almoust like putting it into a keyword). It will be like the cmd or terminal (for the linux users).

if you use command line arguments eg:
int main(int argc, char *argv[])

you can say which word is going to be used eg:

        if(argv[1] == "Hallo")
        cout<<"Hallo Man";

But my program isnt going to use command line arguments, the user is going to enter it in the program itself

Here are a few more egsamples if you didn't understand what i said because i dont know how to say it :(

     int nmap(string line1, string line2);

     int main(int argc, char *argv[])
     {
         if(argv[1] == "nmap")
         {
             for(int i = 2; i < 10; i++)
             {
                  nmap(argv[i]);
             }
         }
     }

that program takes in command line argumenst, mine is suppose to only take in user inputs.
but i get and error if i try to make the user inputs something like that.

Thanks....

Recommended Answers

All 2 Replies

Do you know how to use cin and cout? Have you heard of get() and/or getline()? Using those you can take anything in from the user you want in almost any way you want it. Generally what you should do is read in the entire line and then parse out the line into the comands and data that was provieded. Than you can go through the seperated data to find out what you should do.

i have heard of getline and cin and cout, never of get(). Hoe does it works?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.