@-=ЮрА=-
Заблокирован
|
09.03.2013, 23:52
|
|
KpuB, лови
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| #include <cstring>
#include <iostream>
using namespace std;
char* del_char(char* s, char c);
int main()
{
char chr = '\0';
char text[1024] = {0};//Выделили память под строку
cout<<"Enter text (less than 1024 chars): ";
cin.getline(text, 1024);//Ввод строки с пробелами
cout<<"Enter char to delete from text : ";
cin>>chr;
cout<<"Text after deliting char : "<<strcpy(text, del_char(text, chr))<<endl;
return 0;
}
char* del_char(char* s, char c)
{
char * buf = strchr(s, c);
while( buf )
{
if(buf + 1)
strcpy(buf, buf + 1);
else
buf[0] = '\0';
buf = strchr(buf, c);
}
return s;
} |
|
1
|