Reputation: 39
The text file I am using has the following text:
3 4
5 6
And the output should come 2. It should count pairs.
while (getline(ifs, line)) {
istringstream is(line);
pair<int, int> p;
ifs >> p.first;
ifs >> p.second;
cout << p.first << " " << p.second<< endl;
set<pair<int, int> > set1;
}
Upvotes: 0
Views: 54
Reputation: 25725
it should be is >> p.first;
and is >> p.second;
you must read from stringstream(is
) instead of the filestream(ifs
)
Also just a sidenote, stop using ifs
, line
, p
, etc and give them meaningful names. This not only aids YOU while programming, but also minimizes bugs, improves readability and makes you think in the right direction.
Upvotes: 3