I made a console console application in c++

Dec 20, 2023

#include <iostream>

std::string input;

int main()
{
    while(1)
    {
        std::cout << "my console : ";
        getline(std::cin, input);

        if(input != "quit")
        {
            system((input).c_str());
        }else
        {
            goto a;
        }

        std::cout << "\n";
    }

    a:

    return 0;
}

here you go, have fun, I wrote it myself.


lemme explain how it works

#include <iostream

pastes all the iostream functions and types into this file, thats it, thats all it does, and since its a preproccessor statement (anything after "#") the compiler checks for it first then check for the rest of the code, atleast thats what I think.


std::string input;

this string variable is set so it can be a placeholder for the user input, this is useful for later ofc


system((input).c_str());

this is literally the thing that makes it all work.



int main()
{

    //while loop so it can run continously
    while(1)
    {
        std::cout << "my console : ";
        getline(std::cin, input);


        //this checks of the user inputed "quit"
        if(input != "quit")
        {
            //just pastes the input into the system function which is the meat and potatoes
            system((input).c_str());
        }else
        {
            //if the user did input "quit" it will run the next line of code
            goto a;
        }

        std::cout << "\n";
    }

    a:

    return 0;
}

ok I am lazy now.