What happened? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

What happened?

Note that reverse(sentence) is not the problem. int main() { cout << "enter a sentence" << endl; char* cin << sentence; reverse(sentence); }

4th Sep 2016, 5:37 PM
Edward
7 ответов
+ 1
make this int main() { cout << "enter a sentence" << endl; char sentence; cin >> sentence; reverse(sentence); }
4th Sep 2016, 7:54 PM
bayram akdemir
bayram akdemir - avatar
+ 1
compile error
4th Sep 2016, 7:59 PM
bayram akdemir
bayram akdemir - avatar
+ 1
bayram akdemir is actually correct. everyone commenting has missed the obvious mistake except him. cin requires >> cout requires << i can not figure out what you were trying to do with char* cin...
4th Sep 2016, 10:38 PM
TylerFrost
TylerFrost - avatar
0
What happens when you run your code?
4th Sep 2016, 7:52 PM
Donovan
Donovan - avatar
0
Output?
4th Sep 2016, 7:56 PM
Norbivar
Norbivar - avatar
0
I did. First off I don't have your code for the reverse() function. Second, when you use a char, it only stores one character i.e. 'A'. To store a string of characters use string. I think that's the problem you're having. EDIT: Compiler error: note: Candidate (reverse) expects 2 arguments, 1 provided. So reverse is a part of stl_algo.h If you are going to use features provided by stl, make sure you first know how to use them/ what arguments they require.
4th Sep 2016, 8:01 PM
Donovan
Donovan - avatar
- 1
Try this: int main() { string sentence; cout<<"Enter a sentence.\n"; cin<<sentence; reverse(sentence.begin(), sentence.end()); cout<<sentence<<'\n'; return 0; }
4th Sep 2016, 8:19 PM
Donovan
Donovan - avatar