Quick cmd/cli for C++ using gcc/g++

I have started learning C++ and there are a lot of ways to do one thing. Thank goodness my first programming language was not C++. A quick guide on how to compile and run your C++ code in windows
You can compile in one line in your CMD( Command Line Interface ):
Run the compiled program:

Here “yourfilename.cpp” is the name of your cpp file or source file that you have created. “-o” means that whatever you are going to write after that will be the output file name of your cpp file. And after “-o” we wrote “outfilename.exe”. this will contain the output of your cpp file. You can give your output .exe extension or no extension. It will create the output in .exe extension by default.
But you can give it any other extensions too for fun and it will create the output with that extension like, “yourfilename.txt”. but you cannot run that file since it is not a program file.
By the way, if you get any errors then try “g++” instead of “gcc” in the cmd line.
Now I will show you other ways to compile and run.
C++ is a compiled language. You must write the code and compile it first and then run it. To compile the code write:

This line will create an executable file “a.exe” extension. Since we didn’t give any name the compiler gave a default name “a”. We will run the program by writing this in cmd:

Just writing “a” is enough. “a”, as in, the file that has been created as output after compiling.
Check out my other posts regarding coding, C++, OpenGL, etc.