Here is a link to the minimal code, and if it's gone here it is if your want to run it in cpp.sh:
#include <iostream>
int main()
{
int num1;
int num2;
std::cout << "Enter num1: ";
std::cin >> num1;
std::cout << std::cin.get() << "\n";
std::cout << "Enter num2: ";
std::cin >> num2;
std::cout << std::cin.get() << "\n";
std::cout << "You're nums: " << num1 << ", " << num2 << "!\n";
}
I'm confused on why cin.get()
returns an ASCII 'LF' (parsed to "10"), even though the cin >> num1
already read in that entire line.
Edit:
This promblem arose becaues I was reading in a file using formatted extraction, and I wanted file.get()
to return the next available byte after the newline used by the formatted extraction. Instead, it returned that newline. I'm confused how this does not "mess up" subsequent calls to extract, if the newline is in fact the "next available" character.