end1在vc6.0里有3个错误 怎么解决?

来源:百度知道 编辑:UC知道 时间:2024/06/17 07:26:59
代码:
#include "stdafx.h"
#include "stdio.h"
#include <iostream>
#include <string>
#include <cctype>
using std::cin;
using std::cout;
using std::string;
using std::end1;

int main()
{
string s("Hello Word.....");
string::size_type punct_cnt = 0;
for (string::size_type index = 0; index != s.size(); ++index);
if (ispunct(s[index]))
++punct_cnt;
cout << punct_cnt << "Punctuation chararcters in " << s << end1;

return 0;
}
错误:
--------------------Configuration: primer4 - Win32 Debug--------------------
Compiling...
primer4.cpp
D:\Microsoft Visual Studio\primer4\primer4.cpp(12) : error C2039: 'end1' : is not a member of 'std'
D:\Microsoft Visual Studio\primer4\primer4.cpp(12) : error C2873: 'end1' : symbol cannot be used

其实这个问题可以这样的解决, 在vc当中编译通过的:

#include "stdio.h"
#include <iostream>
#include <string>
#include <cctype>
using std::cin;
using std::cout;
using std::string;
using std::endl;

int main()
{
string s("Hello Word.....");
string::size_type punct_cnt = 0;
for (string::size_type index = 0; index != s.size(); ++index);
if (ispunct(s[index]))
++punct_cnt;
cout << punct_cnt << "Punctuation chararcters in " << s << endl;

return 0;
}

问题出现在:end1大概是手写的错误,是endl,其作用是:

"endl"是一个预定义的iostream操纵符,endl在输出流中插入一个换行符,

然后刷新输出缓冲区(操纵符在iostream上执行的是一个操作,

而不是简单地提供数据)。

endl
是L不是1