A
arunix
hello
here is code from "The C++ Programming langauge" by Bjarne Stroustrup.
the code is working but not showing the output when press ctrl+c it
shows only interrupt and first input.
wht's wrong with this code.
thnaks .
here is the code
#include<iostream>
#include<string>
#include<vector>
using namespace std;
struct Pair{ string name; double val;};
vector<Pair> pairs;
double& value(const string& s)
{
for(unsigned int i=0; i < pairs.size(); i++)
if(s==pairs.name) return pairs.val;
Pair p={s,0};
pairs.push_back(p);
return pairs[pairs.size()-1].val;
}
int main()
{
string buf;
while(cin>>buf) value(buf)++;
for(vector<Pair> :: const_iterator p= pairs.begin(); p != pairs.end
();++p)
cout <<p->name << " : "<<p->val <<"\n";
return 0;
}
here is code from "The C++ Programming langauge" by Bjarne Stroustrup.
the code is working but not showing the output when press ctrl+c it
shows only interrupt and first input.
wht's wrong with this code.
thnaks .
here is the code
#include<iostream>
#include<string>
#include<vector>
using namespace std;
struct Pair{ string name; double val;};
vector<Pair> pairs;
double& value(const string& s)
{
for(unsigned int i=0; i < pairs.size(); i++)
if(s==pairs.name) return pairs.val;
Pair p={s,0};
pairs.push_back(p);
return pairs[pairs.size()-1].val;
}
int main()
{
string buf;
while(cin>>buf) value(buf)++;
for(vector<Pair> :: const_iterator p= pairs.begin(); p != pairs.end
();++p)
cout <<p->name << " : "<<p->val <<"\n";
return 0;
}