Hi I have to do an assignment for a course that includes that I use new stream insertion and stream extraction techniques. On the lecture notes it briefly mentioned cin.get() and getline but not in a very descriptive way. Could anyone please summarize the use of get() when inputting more than a 1 digit float and int. Thank you so much.

example of cin.get().

say a file called num.txt contains the following :
12345677700234.

using cin.get() would first get the number 1, then it may be easier to imagine an arrow pointing to the number 2 , because the number 1 has already been extracted. Then using cin.get() again would ger the number 2, then an imaginary arrow would point to the next number, 3, so if you use cin.get() , then you would get the number 3, and the an imaginary arrow would point to the number 4, then if you use cin.get, you get 4, and so on.

here is an example.

file num.txt contains [123445];

//include all needed libraries.
//preprosessors directives.

int main()
{
ifstream file("num.txt)
...
...

int num;

while(!fil.eof())
{
cin.get(num);
cout<<num;
}

return 0;

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.