+ 5
How to input sentence in C++?
11 Réponses
+ 3
use getline!
+ 11
using namespace std; is considered as bad practice go through this post you will understand
https://www.sololearn.com/discuss/392399/?ref=app
https://www.sololearn.com/discuss/187690/?ref=app
https://www.sololearn.com/discuss/682207/?ref=app
https://www.sololearn.com/discuss/770804/?ref=app
https://www.sololearn.com/discuss/111213/?ref=app
https://www.sololearn.com/discuss/706084/?ref=app
+ 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".
+ 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
+ 7
#include<iostream>
int main(){
int k;
std::cin>>k; //for console input
std::cout<<k; //for console output
return 0;
}
+ 1
Is there a sentence regex? Because then, you could getline() until the regex matches.
0
why you need return 0?
0
but it can work without that
0
why you written std:: if you can written using namespace std;
0
I have a problem with that, I see somewhere the function getline(Cin,a) but i don't shor why haven't >>
0
getline (cin,a)
this?