Handling String Input With Spaces | C++ Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Thanks! When I was writing a little todo list rest project, I was confused on why when there was a space in my string inputs, it would only use the first word inputted and make any following words apart of the next inputs in my loop.

tweetyguy
Автор

so simple and easy to understand, thankyou sir have a nice life!

laurenceflores
Автор

Congratulations 👏👏 on 9000 subscribers
Keep it up 🔥

yousaf
Автор

Amezing sir understand this concept very easily ❤🎉

ganeshmishraa
Автор

You really helped me, man! If I'd be near to u, I'd hug u! Sry for typos, I am Russian. If u can, please, tell me about my mistakes!

Grandfather__
Автор

Wow, sath sath m virat kohli ka promotion b hogya

SagarKumar-kfeo
Автор

I notice the geline didn't work for me when there was a math equation statement that comes before it. When I switched it, it worked fine.

damarcuswilson
Автор

sir,
if we want to take input strings in multiple test cases, it takes the enter as a string;
currently I am handling it like this :

int t;
cin >> t;
while(t--){
string s;

char c;
cin >> c;
getline(cin, s); //example string : the devil in the sky ( I want to take it input as a single string)
s = c + s;
}

//assume that I want to take the same string (the devil in the sky) 3 times, but while running the programme, it will take input 2 times because 1st time it take "enter" as a string(while we input the value 't' then enter)

Is there any better approach ? I have heared about c++ ignore file or something like that but coudn't get it.

please can you solve this problem, please give me the answer as code...
Thanks for reading, you are awssome!

hafizsakib
Автор

Does anyone know how to solve this?
I'm making a program that uses getline(cin, string), and even though it builds and runs without problem, it seems to skip this method and do the next steps.

naniguini