C++ 输出 "Hello world!" 的两种方法:printf 和 cout
本文介绍了C++语言中两种常用的输出语句:printf 和 cout,并分别给出了使用示例。
C语言中的输出语句是使用printf函数,可以通过以下方式输出'Hello world! ':
printf('Hello world!
');
而在C++中,可以使用cout对象和流操作符<<来实现输出,可以通过以下方式输出'Hello world!':
cout << 'Hello world!' << endl;
需要注意的是,C语言中使用的是printf函数,而C++中使用的是cout对象和流操作符<<。
原文地址: https://www.cveoy.top/t/topic/hg2E 著作权归作者所有。请勿转载和采集!