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.
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 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...
@@ramakrishna4092 Yes, we can change the value in main.c. This video should cover how to do this: ruclips.net/video/Wqm1tSzmqkY/видео.html. The example code is here: github.com/portfoliocourses/c-example-code/tree/main/extern_share_global_variable.
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.
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.
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.
literally the goat of c++ courses
short and simple , thanks .
You're welcome Arunya! :-D
i was checking score of virat during video and suddenly you write virat kohli 😎😎
Thank you!! I really needed this
You're welcome! BTW, you have a nice channel and a great singing voice! :-)
so simple and easy to understand, thankyou sir have a nice life!
Amezing sir understand this concept very easily ❤🎉
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.
Wow, sath sath m virat kohli ka promotion b hogya
I'm not sure what that means Sagar. :-)
@@PortfolioCourses He meant that, aside from us receiving some knowledge, Virat Kohli got some promotion as well.
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!
Awesome, I'm glad the video helped you out! :-) Your English seems pretty good to me.
Congratulations 👏👏 on 9000 subscribers
Keep it up 🔥
Thank you very much Yousaf! 😀
thanks that will help me a lot
Are you a kohli fan?
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!
You should be able to use cin.ignore(), like right after cin>>t for example. This video may help: ruclips.net/video/fcygVtDXanM/видео.html. :-)
@@PortfolioCourses It's 100% clear now sir Thanks
Thanks Broooo!\
@@rolandandreiventura1571 You're welcome Roland! 🙂
congratulations sir for 9k sub ...
Thank you Rama! :-)
@@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...
@@ramakrishna4092 Yes, we can change the value in main.c. This video should cover how to do this: ruclips.net/video/Wqm1tSzmqkY/видео.html. The example code is here: github.com/portfoliocourses/c-example-code/tree/main/extern_share_global_variable.
Goat
Thank you! :-)
@@PortfolioCourses not trying to be mean or rude but I guess he was calling Virat, Goat 😂
@@muhammadzaidmuckba9097 hahaha oh I bet you're right Muhammad, that's hilarious! 😂
King Kohli supremacy 👑
:-)
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.
Hi Maria, have you tried clearing the input buffer? Sometimes that can help: ruclips.net/video/fcygVtDXanM/видео.html. 🙂
@@PortfolioCourses Thank you very much, but it seems this method is not recognized by my IDE (Code::Blocks).
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.
@@PortfolioCourses I solved it, I had to use some libraries. Thank you👍👍
@@naniguini Great! 🙂
how does getline differ from get?
I think this is a good explanation here: stackoverflow.com/a/55308322. :-)
thank you!!
You're welcome Jake! :-)
getline doesnt work in codeblocks
What do you use instead for CodeBlocks?
thanks
Virat fan