Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <Windows.h> // нужна для работы SetConsole
- using namespace std;
- void DelChar(char* str, char ch) {
- char* temp = new char[strlen(str) + 1];
- int count = 0;
- for (int i = 0; i <= strlen(str); i++) {
- if (str[i] != ch) {
- temp[count++] = str[i];
- }
- }
- strcpy(str, temp);
- }
- int main() {
- SetConsoleCP(1251); // установка кодировки 1251 в поток ввода
- SetConsoleOutputCP(1251); // установка кодировки 1251 в поток вывода (то же, что setlocale)
- char line[40];
- char ch;
- cout << "Введите строку: ";
- gets_s(line);
- cout << "Введите символ: ";
- cin >> ch;
- DelChar(line, ch);
- cout << line << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment