#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main( void )
{    
    //正确
    const string str2 = "ab";
    cout << isspace(str2[2]) << endl;
//    报错
//    string str1 = "ab";
//    cout << isspace(str1[2]) << endl;
    return 0;
}
在vs2010中,是编译器的问题么?
应该不会,之所以出错,估计是isspace实现的版本问题,对0的处理问题
string str1 = "ab";
 char* ch = &(str1[2]);
 cout << isspace(*ch) << endl;
Debug时看看ch的地址和str1指向的地址内容,比较一下