您是否可以将此c printf语句转换为c ++ cout语句?
printf("\n\nLIST OF MOVIES:\n\n");
答案 0 :(得分:6)
像这样:
std::cout << "\n\nLIST OF MOVIES:\n\n";
答案 1 :(得分:2)
最有效的方法是
std::cout << "\n\nLIST OF MOVIES:\n" << std::endl;
因为endl也会刷新缓冲区。
答案 2 :(得分:0)
std::cout<<"\n\nLIST OF MOVIES:\n\n";
或
std::cout<<endl<<endl<<"LIST OF MOVIES:"<<endl<<endl;
答案 3 :(得分:0)
这不是干净的解决方案,而且真的不屑一顾,你可以使用预处理器用std :: cout替换printf:
#define printf(text) std::cout << text
int main()
{
printf("\n\nLIST OF MOVIES:\n\n");
}