string words[5]; for (int i = 0; i < 5; ++i) { words[i] = "word" + i; } for (int i = 0; i < 5; ++i) { cout<<words[i]<<endl; } I expected result as :
word1 . . word5 Bu it printed like this in console:
word ord rd d Can someone tell me the reason for this. I am sure in java it will print as expected.
to_stringfunction.