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
Invalid arguments ' Candidates are: std::basic_ostream<char,std::char_traits<char>> & write(const char *, int) '
原文地址:https://www.cnblogs.com/sageloris/p/11452268.html
时间: 2024-10-08 20:50:26