Advertisement
thepowderguy

CAT

Feb 21st, 2014
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. #include <string> //import the string library
  2. #include <iostream> //import IO stuff
  3. #include <windows.h> //import console API
  4. #include <sstream> //import more string stuff
  5. //NOTHING HERE!!!!!!!!
  6. using namespace std; //use the standard namespace
  7. //NOTHING HERE!!!!!!!!
  8. int main(int argc, const char* argv[]) // The main function
  9. {
  10.     string title = "Console IO"; // New string
  11.     WORD conattr = 7; // New word, (word = data type)
  12.     stringstream ss; // New stringstream, (like a string but better)
  13.     FreeConsole(); // detatch itself form the current console
  14.     AllocConsole(); // Allocate a new console (create a new one)
  15.     if (argc > 1) // if the # of arguments > 1
  16.     {
  17.         title = argv[1]; // set title to args[1]
  18.     }
  19.     SetConsoleTitle(title.c_str());  //set the title of the console to "title"
  20.     if (argc > 2) // if the # of arguments > 2
  21.     {
  22.         ss << hex << argv[2]; // set ss to the hexadecimal value of argv[2]
  23.         ss >> conattr; // set conattr to ss
  24.         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), conattr); // set the color of the console to conattr
  25.     }
  26.     if (argc > 3) // if the # of arguments > 3
  27.     {
  28.         title = ""; // I think you can get this one.......
  29.         title = argv[3]; // This one too......
  30.         title += "\n"; // append newline to title
  31.         WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), title.c_str(), title.length(), NULL, NULL); // print title to the current console
  32.     }
  33.     string io; // new string called io
  34.     while (cout.good() & cin.good()) // while input and output is valid, {
  35.     {
  36.         getline(cin, io); // get a line from the standard input, copy it to io
  37.         cout << io << endl; // output io to standard output
  38.     }
  39.     return 0; //What do you think this means? *sarcasm*
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement