How to Redirect Cout and Cin
C++ is a programming language introduced by Bell Labs in 1979. Originally called "C with Classes," it was renamed C++ in the early 1980s. The C++ functions "cin" and "cout" are part of the Standard Template Library and are written using a notation that implies a directional flow. You must add this redirection into your code to properly use these functions to flow input to the application and to direct output from the application.
Instructions
-
-
1
Open the C++ document in your preferred text editor and locate the "main" function.
-
2
Type "std::cin >> variable;" without quotation marks. This prompts a user to enter a value called "variable" and redirects it to your program from the console.
-
-
3
Type "std::cout << "Text" << endl;" without quotation marks to direct data from the program to console. Replace "Text" with the text or variable you'd like to display. The final "endl" signifies that the line ends.
-
1