@zeland
0 / 0 / 0
Регистрация: 23.08.2013
Сообщений: 1
|
27.08.2013, 14:01
|
|
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
| #include <iostream>
#include <fstream>
#include <string.h>
#include <new>
void digits(char mass[100]);
void alphas(char mass[100]);
void puncts(char mass[100]);
using namespace std;
int main ()
{
char digit[100],alph[100],punct[100];
char *s = new char[100];
ifstream f ("Text.txt",std::ios::in);
if(!f)
{
cout<<"Cannot open file...\n";
return 1;
}
f.getline(s,100);
cout<<"All text: "<< s <<endl;
digits(s);
alphas(s);
puncts(s);
ifstream f1("Digit.txt",std::ios::in);
f1.getline(digit,100);
cout<<"All digits: "<<digit<<endl;
fstream f2("Alpha.txt",std::ios::in);
f2.getline(alph,100);
cout<<"All letters: "<<alph<<endl;
fstream f3("Punct.txt",std::ios::in);
f3.getline(punct,100);
cout<<"All characters: "<<punct<<endl;
f.close();
f1.close();
f2.close();
f3.close();
delete []s;
return 0;
}
void digits(char mass[100])
{
ofstream outfile("Digit.txt",std::ios::out);
for(int i=0;i<strlen(mass);i++)
if (isdigit(mass[i]))
outfile.put(mass[i]);
outfile.close();
}
void alphas(char mass[100])
{
ofstream outfile("Alpha.txt",std::ios::out);
for(int i=0;i<strlen(mass);i++)
if (isalpha(mass[i]))
outfile.put(mass[i]);
outfile.close();
}
void puncts(char mass[100])
{
ofstream outfile("Punct.txt",std::ios::out);
for(int i=0;i<strlen(mass);i++)
if (ispunct(mass[i]))
outfile.put(mass[i]);
outfile.close();
} |
|
0
|