#include
#include
#include
int main()
{
std::string::size_type lCount = 0, wCount = 0;
std::string str = "Avalon Excaliburn", word;
std::istringstream istr(str);
while (istr >> word) {
lCount += word.size();
++ wCount;
}
std::cout << str << "\n" << wCount << "\t" << lCount << std::endl;
system("pause>nul");
return 0;
}
C语言字符串的学习,输入指定字符串,并且计算字符串的位数
谭浩强的C语言程序设计有一个这样的例子