0

How to write two strings in char array so it will print correctly?

https://code.sololearn.com/cyumtAD9c7LL/?ref=app

3rd Mar 2021, 6:56 PM
TeaserCode
3 Answers
+ 1
'i' is not initialized, therefore the strcpy() operations are undefined behaviour. Also, std::cin.get() doesn't seem to trigger the input box on SoloLearn, so the strings will be empty anyway. You could place a macro like #define dummy std::cin >> somewhere to force the input though. However, note get() will not extract the final newline character if found, unlike getline(), so two successive calls like that would only store the first string.
3rd Mar 2021, 7:32 PM
Shadow
Shadow - avatar
0
I have found it, first you have to inicialize strings to separate lines in array, then copy and at last print them.
3rd Mar 2021, 7:56 PM
TeaserCode