+ 1
Why isn't it outputting int correctly?
I want it to work like: you input number and then it gives you "world 1; world 2; world 3; world n..." But for some reason it just outputs "world; orld; rld; ld; d;" https://code.sololearn.com/c69W87WqaOy2/?ref=app
8 odpowiedzi
+ 2
Write << instead of +.
A string literal is a pointer and when you add an int to it, it's like you use [i] with it.
+ 2
Use your same code, but instead of i + "world", use to_string(i) + "world".
Either that or use HonFu's method
+ 1
No problem, SummerWizard👍🏼
0
Use to_string(i)
0
And start the loop from i = 1
0
Thomas Williams, could you please expain how to use to_string(i), I've just started learning c++
0
Thomas Williams thanks, the method above worked fine