at 9.03 minutes in the video it is told that the newline char will work i.e. \n will help enter the next line…but it isn’t working,instead showing \n as it is in the output
Introduction to cin.get()
Hey @Mitali_Jain
Can you share the code?
coz writing cout << ‘\n’ actually helps enter the next line.
Not in cout…it’s when giving input in the console
The code is:
char ch;
ch=cin.get();
while(ch!=’.’){
cout<<ch;
ch=cin.get();
}
And I inputed
(Hello world\n hello.)
Which gave the output
(Hello world\n hello)
@Mitali_Jain
Oh, see basically when you print it in a cout statement, then only it takes to the new line, otherwise by this method, where you input a string and print it, it’s gonna give exactly the same as what you inputted.
But in the video it is told that cin.get() reads the special characters like spaces ans newline char from the input buffer.
You can confirm it by referring the video ‘cin.get() for input’ in prog fundamentals 2 at 9.03 minutes
it read space and enter and not \n, \t, etc
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.