C++ getline Function | Reading an Entire Line from Streams | Video Tutorial

preview_player
Показать описание
In this c++ Video tutorial, you will learn how you can read an entire line from a stream using the getline() function in c++ programming language.

You are gonna learn what happens when we try to read an entire line using stream extraction operators, what is the syntax of getline function, how to use it in detail with example.

Learn Programming in HINDI at our youtube channel

Catch us on SocialMedia
Рекомендации по теме
Комментарии
Автор

No matter where I go, my Indian bros, are always on c++ tutorials! I wonder why you learned c++ instead of java.

playonce
Автор

That was very clear and concise. 
I appreciate it.

colin
Автор

ah great, the only good source i found to understand getline. ty.

Raidar
Автор

Thank you! I like how you go directly to the point

javiercardoso
Автор

That's a legend right here, everything makes sense now🔥

nicholasachuz
Автор

This was so simple to understand.
Everywhere I checked I got a super complex answer.

izzycspp
Автор

Very clear and simple! Thank you so much!

lucasnguyen
Автор

That was a nice, straight to the point explanation.

maty
Автор

I am teaching myself to code c++ by watching your videos. Thank you for all of the work you do. My question regarding this lesson is why when I write:

#include

string strt, city, state;

cout << "Enter home address: ";
getline (cin, strt);
cout << "Enter city: ";
cin >> city;
cout << "Enter state: ";
cin >> state;



And compile the code, it reads-

Enter home address: 35 Bethel Street
Enter city: Enter state: _

Fyi...the code is within an "else", if it matters. Thanks.

atroche
Автор

Exactly what i had been looking for, ty

gargolismc
Автор

Thank you Anil!


Appreciate your efforts!


Regards
Girish

girishdevappa
Автор

So amazing lecture i don't have words to thanks ❤❤❤❤❤

HassanKhan-mh
Автор

Well communication sir keep it up i understood this lecture very well

CS_lover_
Автор

Can you explain why we put cin inside the parenthesis? Is there anything else we can place to replace that?

Crispy.Potato
Автор

Can u tell me please what is the problem in the trying the following:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s, a;
cout<<"Enter a string: ";
cin>>s;
cout<<"The string you entered is: "<<s<<endl;
cout<<"Enter your name: ";
getline(cin, a);
cout<<"\nHi "<<a;
return 0;
}

It is just reading the first string and showing its output but not in the case of when I'm doing the following it is working properly:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s, a;
cout<<"Enter your name: ";
getline(cin, a);
cout<<"Hi "<<a;
cout<<"\nEnter a string: ";
cin>>s;
cout<<"The string you entered is: "<<s<<endl;
return 0;
}

sourabmandal
Автор

In a void function with arguments passed by value, does the getline function still take them by reference?

ApppleMilkk
Автор

Can I use getline function in a loop to store dynamic data..?

redlamaravind
Автор

I am super late to this video and i really just started to learn C++, but if you could answer this for me that would be great


Why is it that when you do the two cin streams, it automatically reads from the first input, and it doesnt ask you to input a second value? is it because it is the same string?

yeezusreetus
Автор

So it's like function "gets" in c right?

pranavjoshi
Автор

Thanx bruh... You're doing great job✌

aishwarya