Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- char** text = new char*[100]{};
- char* buf = new char[300]{};
- int textPos = 0;
- char addMore = 'Y';
- while ((addMore == 'Y' or addMore == 'y') and textPos < 100)
- {
- std::cin.getline(buf, 300);
- int len = strlen(buf) + 1;
- text[textPos] = new char[len];
- strcpy_s(text[textPos], len, buf);
- textPos++;
- std::cout << "\nAdd another line? [Y/y to add]";
- std::cin >> addMore;
- std::cin.ignore();
- }
- std::cout << "Here is yor lines \n";
- for (textPos = 0; text[textPos]; textPos++)
- {
- std::cout << text[textPos] << '\n';
- }
- for (textPos = 0; text[textPos]; textPos++)
- {
- delete[] text[textPos];
- }
- delete[] text;
- delete[] buf;
- }
Advertisement
Add Comment
Please, Sign In to add comment