How to input sentence in C++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How to input sentence in C++?

16th Apr 2018, 12:06 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
11 Answers
+ 3
use getline!
16th May 2018, 2:40 PM
Sadaam Linux
Sadaam Linux - avatar
+ 9
In C and C++ programs the main function is of type int and therefore it should return an integer value. The return value of the main function is considered the "Exit Status" of the application. On most operating systems returning 0 is a success status like saying "The program worked fine".
16th Apr 2018, 12:26 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 9
yeah it's optional too use but I preferd to use return value because every function if it is not void return some value
16th Apr 2018, 12:30 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 7
#include<iostream> int main(){ int k; std::cin>>k; //for console input std::cout<<k; //for console output return 0; }
16th Apr 2018, 12:21 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
Is there a sentence regex? Because then, you could getline() until the regex matches.
16th Apr 2018, 2:03 PM
Timon Paßlick
0
why you need return 0?
16th Apr 2018, 12:23 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
but it can work without that
16th Apr 2018, 12:27 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
why you written std:: if you can written using namespace std;
16th Apr 2018, 12:32 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
I have a problem with that, I see somewhere the function getline(Cin,a) but i don't shor why haven't >>
16th Apr 2018, 12:35 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
getline (cin,a) this?
16th Apr 2018, 12:43 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar