Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- char* input(char str[], int size, char sim, int pos) {
- char* newStr = new char[size + 1];
- int count = 0;
- while (count < pos) {
- newStr[count] = str[count];
- ++count;
- }
- newStr[count] = sim;
- ++count;
- while (count < size + 1) {
- newStr[count] = str[count - 1];
- ++count;
- }
- return newStr;
- }
- void print(char* str, int size) {
- for (int i = 0; i < size; ++i) {
- cout << str[i];
- }
- cout << endl;
- }
- int main()
- {
- char str[] = "I want everything to be fine!";
- int size = sizeof(str);
- cout << "Size = " << size << endl;
- cout << "Enter the simbol which you want to input into the text and position of it by space: ";
- char sim;
- int pos;
- cin >> sim >> pos;
- char* newStr = input(str, size, sim, pos);
- print(newStr, size + 1);
- delete[] newStr;
- return 0;
- }
Add Comment
Please, Sign In to add comment