Invalid arguments ' Candidates are: std::basic_ostream<char,std::char_traits<char>> & write(const char *, int) '

const char* p = "hello itcast";

cout.write(p,strlen(p)) << endl;
cout.write(p,strlen(p) - 4) << endl;
cout.write(p,strlen(p) - 4) << endl;

代码十分简单,通过对比vs,得知gcc调用的是ostream.tcc文件中的write函数write(const _CharT* __s, streamsize __n)。

vs中是定义在ostream文件中的write(const _Elem* _Str,streamsize _Count),gcc中有write(const char_type* __s, streamsize __n);源码地址https://gcc.gnu.org/onlinedocs/gcc-4.7.4/libstdc++/api/a01220_source.html

猜你喜欢

转载自www.cnblogs.com/sageloris/p/11452268.html