Check out example codes for "run program until ctrl-d c++". It will help you in understanding the concepts better.

Code Example 1

std::string line; 
while (std::getline(std::cin, line))
{
    std::cout << line << std::endl;
}

Learn ReactJs, React Native from akashmittal.com