18th Jul 2021, 5:09 AM
Harsh Pratap Singh
Harsh Pratap Singh - avatar
4 Respostas
+ 2
You made a stack of string so its wrong. here is the corrected code - https://code.sololearn.com/cZMJmdN3pKqZ/?ref=app
18th Jul 2021, 5:37 AM
syscall
syscall  - avatar
+ 2
In the condition of your inner while loop, you need to check first if 'i' is smaller than the length, before accessing the character at position 'i'. Right now, you compare the character at position 'i' to a space character, before knowing whether 'i' is a valid position in the string. The correct condition would be: ... while ( i < len && s.at( i ) != ' ' ) ... This way around works because the && operator is mandatory to have a sequence point after the first clause, and won't execute the second expression in case the first already evaluates to false.
18th Jul 2021, 7:26 AM
Shadow
Shadow - avatar
0
get each char of the sentence onto stack and after pop each letter from there.
18th Jul 2021, 5:13 AM
Oma Falk
Oma Falk - avatar
0
Input My name is Harsh Output Harsh is name myThis kind of output I want
18th Jul 2021, 5:44 AM
Harsh Pratap Singh
Harsh Pratap Singh - avatar