Есть следующий код: #include <iostream> char* buildstr(char, int); int main() { using namespace std; char ch; int times; cout << "Enter char: "; cin >> ch; cout << "Enter the amount of chars which will be printed: "; cin >> times; char* ps = buildstr(ch, times); cout << ps << '\n'; delete [] ps; ps = buildstr('+', 5); cout << ps << "END" << ps << '\n'; delete [] ps; return 0; } char* buildstr(char ch, int n) { char* pstr = new char[n + 1]; pstr[n] = '\n'; while (n-- > 0) pstr[n] = ch; return pstr; } Код #include <iostream> char* buildstr(char, int); int main() { using namespace std; char ch; int times; cout << "Enter char: "; cin >> ch; cout << "Enter the amount of chars which will be printed: "; cin >> times; char* ps = buildstr(ch, times); cout << ps << '\n'; delete [] ps; ps = buildstr('+', 5); cout << ps << "END" << ps << '\n'; delete [] ps; return 0; } char* buildstr(char ch, int n) { char* pstr = new char[n + 1]; pstr[n] = '\n'; while (n-- > 0) pstr[n] = ch; return pstr; } При выводе я получаю следующее: Спойлер Enter char: a Enter the amount of chars which will be printed: 10 aaaaaaaaaa ¤¤¤¤▌▌▌▌▌▌▌▌▌W$J)▌♂ +++++ ¤¤¤¤END+++++ ¤¤¤¤ D:\cppProjects\Exercises\x64\Debug\Exercises.exe (process 28788) exited with code 0. Press any key to close this window . . . Вопрос: что за хуйня? Почему при выводе выходят все эти странные символы? Я возможно догадываюсь что проблема в указателях на массив (new char[n + 1]), но я весь код в точности переписал из книги, так что не могу понять, где здесь ошибка. Помогите