ostream中put()用于显示字条,write()用于显示字符串,它有两个参数,第一个参数为字符中的地址,第二个参数指出要显示多少个字符。

#include

using namespace std;

void main()

{

char *pstr="Hello word";

cout.put('A').put('m').put(70);

cout.put('\n');

cout.write(pstr,5);

cout.write(pstr+5,6);

cout<<endl;

cout.write("happy",5);

cout<<endl;

}

C++学习笔记 -put()和write()的区别

 

 

相关文章:

  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-01-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案