-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_1.cc
59 lines (47 loc) · 840 Bytes
/
test_1.cc
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
#include<fstream>
#include <iostream>
#include<string>
using namespace std;
void test_of()
{
ofstream ofs;
ofs.open("*test_1.txt",ios::out);
ofs << "tangjinyu3120210912130"<<endl;
ofs.close();
}
void test_if( )
{
ifstream ifs;
ifs.open("*test_1.txt",ios::in);
if(!ifs.is_open())
{
cout <<" file can't find "<< endl;
}
char buf[1024]={0};
char bu[1024]={0};
int num,i,j=0;
while(ifs >> buf)
{
cout << buf;
}
cout << endl;
for ( i = 0; i < 1024;i++)
{
if(buf[i]>='A' && buf[i]<='z')
{
bu[j]=buf[j];
j++;
}
}
for (int i = 0; i < j; i++)
{
cout << bu[i];
}
cout <<endl;
cout <<i<<" "<< j;
}
int main()
{
test_of();
test_if();
}