Handling String Input With Spaces | C++ Tutorial

  Рет қаралды 38,465

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 51
@tweetyguy7347
@tweetyguy7347 8 ай бұрын
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.
@AdverTyy
@AdverTyy 7 ай бұрын
literally the goat of c++ courses
@arunyagoojar1889
@arunyagoojar1889 2 жыл бұрын
short and simple , thanks .
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome Arunya! :-D
@NikitaNair
@NikitaNair 10 ай бұрын
Thank you!! I really needed this
@PortfolioCourses
@PortfolioCourses 10 ай бұрын
You're welcome! BTW, you have a nice channel and a great singing voice! :-)
@HiteshKumar-lu9wj
@HiteshKumar-lu9wj 4 сағат бұрын
i was checking score of virat during video and suddenly you write virat kohli 😎😎
@laurenceflores9807
@laurenceflores9807 Жыл бұрын
so simple and easy to understand, thankyou sir have a nice life!
@ganeshmishraa
@ganeshmishraa Жыл бұрын
Amezing sir understand this concept very easily ❤🎉
@damarcuswilson1
@damarcuswilson1 10 ай бұрын
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.
@SagarKumar-kf7eo
@SagarKumar-kf7eo 2 жыл бұрын
Wow, sath sath m virat kohli ka promotion b hogya
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
I'm not sure what that means Sagar. :-)
@rahulrai1530
@rahulrai1530 2 жыл бұрын
@@PortfolioCourses He meant that, aside from us receiving some knowledge, Virat Kohli got some promotion as well.
@Grandfather__
@Grandfather__ Жыл бұрын
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!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Awesome, I'm glad the video helped you out! :-) Your English seems pretty good to me.
@yousaf2003
@yousaf2003 2 жыл бұрын
Congratulations 👏👏 on 9000 subscribers Keep it up 🔥
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you very much Yousaf! 😀
@mohanedalbkry8921
@mohanedalbkry8921 6 ай бұрын
thanks that will help me a lot
@sportgamer4482
@sportgamer4482 8 ай бұрын
Are you a kohli fan?
@hafizsakib2734
@hafizsakib2734 2 жыл бұрын
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!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You should be able to use cin.ignore(), like right after cin>>t for example. This video may help: kzbin.info/www/bejne/nJTcmImqeb2UpK8. :-)
@hafizsakib2734
@hafizsakib2734 2 жыл бұрын
@@PortfolioCourses It's 100% clear now sir Thanks
@rolandandreiventura1571
@rolandandreiventura1571 Жыл бұрын
Thanks Broooo!\
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@rolandandreiventura1571 You're welcome Roland! 🙂
@ramakrishna4092
@ramakrishna4092 2 жыл бұрын
congratulations sir for 9k sub ...
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you Rama! :-)
@ramakrishna4092
@ramakrishna4092 2 жыл бұрын
​@@PortfolioCourses hi sir I came across this question after seeing your video about extern I have a question suppose in my .h file I declare a global variable and linked to my main. c with the help of extern , is it possible to change the value in main .c file (which is declared in another file ) , if possible how to achieve this , it will be helpful to my studies if you do a video on this topic , thanks for helping and a quick response for your sub .... Thanks again sir...
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
@@ramakrishna4092 Yes, we can change the value in main.c. This video should cover how to do this: kzbin.info/www/bejne/jaLQYqeJr9Kkobs. The example code is here: github.com/portfoliocourses/c-example-code/tree/main/extern_share_global_variable.
@AlbeezyOfc
@AlbeezyOfc Жыл бұрын
Goat
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thank you! :-)
@muhammadzaidmuckba9097
@muhammadzaidmuckba9097 Жыл бұрын
@@PortfolioCourses not trying to be mean or rude but I guess he was calling Virat, Goat 😂
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@muhammadzaidmuckba9097 hahaha oh I bet you're right Muhammad, that's hilarious! 😂
@danish15
@danish15 Жыл бұрын
King Kohli supremacy 👑
@PortfolioCourses
@PortfolioCourses Жыл бұрын
:-)
@naniguini
@naniguini 2 жыл бұрын
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.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Hi Maria, have you tried clearing the input buffer? Sometimes that can help: kzbin.info/www/bejne/nJTcmImqeb2UpK8. 🙂
@naniguini
@naniguini 2 жыл бұрын
@@PortfolioCourses Thank you very much, but it seems this method is not recognized by my IDE (Code::Blocks).
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Hmm, if it gives you an error message, you could google the error message to try to help. If it just doesn't work and has no error message, then maybe it's not solving the problem in your code. The code for that demo is here, I suspect it should work in Code::Blocks too as it is standard C++: github.com/portfoliocourses/cplusplus-example-code/blob/main/clear_input_buffer.cpp.
@naniguini
@naniguini 2 жыл бұрын
@@PortfolioCourses I solved it, I had to use some libraries. Thank you👍👍
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
@@naniguini Great! 🙂
@Randomkloud
@Randomkloud Жыл бұрын
how does getline differ from get?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I think this is a good explanation here: stackoverflow.com/a/55308322. :-)
@KuriZaki
@KuriZaki Жыл бұрын
thank you!!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Jake! :-)
@ralphordiz6502
@ralphordiz6502 Жыл бұрын
getline doesnt work in codeblocks
@iJuMp8
@iJuMp8 Жыл бұрын
What do you use instead for CodeBlocks?
@MubahDotkom
@MubahDotkom Жыл бұрын
thanks
@LearningCorner2011
@LearningCorner2011 8 ай бұрын
Virat fan
Do-While Loops | C++ Tutorial
11:51
Portfolio Courses
Рет қаралды 1,6 М.
you will never ask about pointers again after watching this video
8:03
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2 МЛН
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,5 МЛН
Learn Any Programming Language In 3 Hours!
22:37
Code With Huw
Рет қаралды 551 М.
Operator Overloading Using Friend Functions | C++ Tutorial
15:04
Portfolio Courses
Рет қаралды 10 М.
How Strings Work in C++ (and how to use them)
19:26
The Cherno
Рет қаралды 467 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 825 М.
how Google writes gorgeous C++
7:40
Low Level
Рет қаралды 951 М.
C++ File Input and Output
10:21
Shmeowlex
Рет қаралды 67 М.
why do header files even exist?
10:53
Low Level
Рет қаралды 431 М.
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 1,8 МЛН
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2 МЛН