求大神指点我的代码错在哪,感谢!
这个是我做C++PrimerPlus(第五版)第9章的第2道编程题的代码#include <iostream>
#include <string>
void strcount(string s);
int main()
{
using namespace std;
string str;
cout<<"Enter a line: \n";
getline(cin,str);
while(cin)
{
strcount(str);
cout<<"Enter next line (empty line to quit): \n";
getline(cin,str);
}
cout<<"Bye\n";
return 0;
}
void strcount(string s)
{
using namespace std;
static int total=0;
int count=s.size();
total+=count;
cout<<"\""<<s<<"\" contains "<<count<<" characters\n";
cout<<total<<" characters total\n";
}