0
How to write two strings in char array so it will print correctly?
3 Antworten
+ 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.
0
I have found it, first you have to inicialize strings to separate lines in array, then copy and at last print them.