+ 1

Need some help!

https://code.sololearn.com/cNQviqp4A6ti/?ref=app This is a code i wrote that results in some kind of error i can not interpret. I need some help. Thanks in advance.

15th Dec 2019, 5:35 PM
Salman Nazeer
Salman Nazeer - avatar
1 Réponse
+ 1
1. You have not allocated any memory for your C-style string. You should allocate memory first. As for example: char str[50]; 2. You should terminate your string with null(\0) inside getting() . Otherwise the string will overflow while printing. 3. There are some issues with using new line as string-terminator while taking input in "Sololearn coding interface". It will work fine in PC. We can use # or other symbol as string-terminator. The corrected code is attached below. It's recommend to use string class in C++ like this- string str; cin>>str; This is much more efficient and saves the time needed to write getstring() https://code.sololearn.com/chdYYjRqgRkc/?ref=app
15th Dec 2019, 7:01 PM
Jawwad Hossain
Jawwad Hossain - avatar