Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- char* del(char str[], int size, int num) {
- char* newStr = new char[size - 1];
- int counter = 0;
- while (counter < num) {
- newStr[counter] = str[counter];
- ++counter;
- }
- ++counter;
- while (counter < size) {
- newStr[counter - 1] = str[counter];
- ++counter;
- }
- 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 number of simbol which you want to delete: ";
- int num;
- cin >> num;
- char* newStr = del(str, size, num);
- print(newStr, size - 1);
- delete[] newStr;
- return 0;
- }
Add Comment
Please, Sign In to add comment