Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string> //import the string library
- #include <iostream> //import IO stuff
- #include <windows.h> //import console API
- #include <sstream> //import more string stuff
- //NOTHING HERE!!!!!!!!
- using namespace std; //use the standard namespace
- //NOTHING HERE!!!!!!!!
- int main(int argc, const char* argv[]) // The main function
- {
- string title = "Console IO"; // New string
- WORD conattr = 7; // New word, (word = data type)
- stringstream ss; // New stringstream, (like a string but better)
- FreeConsole(); // detatch itself form the current console
- AllocConsole(); // Allocate a new console (create a new one)
- if (argc > 1) // if the # of arguments > 1
- {
- title = argv[1]; // set title to args[1]
- }
- SetConsoleTitle(title.c_str()); //set the title of the console to "title"
- if (argc > 2) // if the # of arguments > 2
- {
- ss << hex << argv[2]; // set ss to the hexadecimal value of argv[2]
- ss >> conattr; // set conattr to ss
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), conattr); // set the color of the console to conattr
- }
- if (argc > 3) // if the # of arguments > 3
- {
- title = ""; // I think you can get this one.......
- title = argv[3]; // This one too......
- title += "\n"; // append newline to title
- WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), title.c_str(), title.length(), NULL, NULL); // print title to the current console
- }
- string io; // new string called io
- while (cout.good() & cin.good()) // while input and output is valid, {
- {
- getline(cin, io); // get a line from the standard input, copy it to io
- cout << io << endl; // output io to standard output
- }
- return 0; //What do you think this means? *sarcasm*
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement