#include <iostream>
#include <string>
int main() {
std::string line;
while (std::getline(std::cin, line)) {
// Process 'line' here
}
return 0;
}
#include <iostream>
: Includes the input/output stream library for handling input and output operations.#include <string>
: Includes the string library to work with string data types.int main() { ... }
: Entry point of the program.std::string line;
: Declares a string variable named line
to store input.while (std::getline(std::cin, line)) { ... }
: Uses a while
loop to read input from std::cin
(standard input) using std::getline
. It reads a line of text until the end-of-file (EOF) is encountered.// Process 'line' here
: Placeholder comment indicating where you can process each line of input within the loop.return 0;
: Indicates successful completion of the main
function.