how to add number 10 to my code below? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to add number 10 to my code below?

It is a very simple code, you can find a description in it. https://code.sololearn.com/c4b0jGew6caA/?ref=app

29th Dec 2020, 3:56 PM
Hakam
3 Answers
+ 1
Lothar The code seems to run perfectly fine using my other compiler, i don't know why perhaps there are different types of compilers.Can you recommend another compiler android apk please and thank you for your help, i appreciate it.
29th Dec 2020, 7:16 PM
Hakam
+ 6
Hakam , there are 2 main issues in the code, maybe also some more. - in the header of the for loop, you compare variable "i" with the length of the input string. "i" is a signed int, and result of <string>.length() is an unsigned int. This will create a compiler error, so both parts of the expression has to be the same integer type. - The sololearn compiler timed out the code, so it looks like there is an infinite loop. Maybe you should think about the way you process the input string. if it has always the same structure like <number><space><text>, you could also try to split the string. This will create 2 elements, that can be stored in 2 variables or in a vector. After this the replacement can be done.
29th Dec 2020, 6:08 PM
Lothar
Lothar - avatar
+ 1
Use stoi from the string header file. You can then test for a 1, 0 and 10 as integers. http://www.cplusplus.com/reference/string/stoi/ edit... or use strtok from the cstring header file. http://www.cplusplus.com/reference/cstring/strtok/
29th Dec 2020, 7:58 PM
rodwynnejones
rodwynnejones - avatar