forked from mrchuanxu/RegularNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrstream.cpp
More file actions
69 lines (64 loc) · 1.36 KB
/
strstream.cpp
File metadata and controls
69 lines (64 loc) · 1.36 KB
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
#include <iostream>
#include <sstream>
#include <vector>
#include <fstream>
#define UV_HANDLE_FIELDS \
void* data; \
int* pint;
using namespace std;
// class uv__loop_t{
// public:
// int closing_handles;
// int stop_flag;
// private:
// int update_time;
// };
struct PersonInfo
{
string name;
vector<string> phones;
UV_HANDLE_FIELDS;
};
int main()
{
// uv__loop_t* loop;
string line, word;
vector<PersonInfo> people;
ifstream ifiles("phone.txt");
istringstream record;
while (getline(ifiles,line))
{
// cout << "ifiles" << endl;
PersonInfo personInfo;
record.clear();
record.str(line);
record >> personInfo.name;
int i = 13;
personInfo.data = &i;
cout << personInfo.data <<endl;
while (record >> word)
personInfo.phones.push_back(word);
people.push_back(personInfo);
}
for (const auto &entry : people)
{
cout << entry.name <<endl;;
ostringstream osNums;
for (const auto &nums : entry.phones)
{
osNums << nums; // 向ostringstream写入,进行检验就很有用!
cout << nums <<endl;;
}
}
ifiles.close();
// const int csint = 12;
// const int *const pint = &csint;
// cout << *pint << endl;
// cin.tie(&cout);
// ostream *old_tie = cin.tie(nullptr);
// cin.tie(&cerr);
// cin.tie(old_tie);
//int timeout;
// cout << timeout << endl;
return 0;
}