如何在C++的下一行打印我的名字
how to print my name in next line in C++
我想在新行中打印我的名字十次。这是我的代码:
#include "stdafx.h"
#include<iostream>
using namespace std;
void main()
{
int i;
for (i = 1; i <= 10; ++i)
cout << "krishna " ;
getchar();
}
我需要在第一行打印后休息或""。如何获得?
你不应该使用 std::endl;
for (i = 1; i <= 10; ++i)
cout << "krishna " << endl;
确实(在收到评论后)最好使用""(仅限 Windows)
查看此常见问题解答 -> https://isocpp.org/wiki/faq/input-output#endl-vs-slash-n
您可以使用 endl 或 ''。您的代码将如下所示-
for (i=1;i<=10;i++)
cout<<"Krishnan";
相关文章:
- 如何使代码打印文本文件中的第一行?
- 如何让字符数组在一行而不是多行中打印出来?
- 有时打印一行,有时打印三行
- 如何在同一行内打印和返回?
- 如何在循环中打印两个相邻的行,同时在 c++ 中将它们都保留在一行中
- 如何在c ++中以一行(水平)打印两个文件的数据?如给定的.这两种形式来自两个不同的文本文件
- 使用更改此变量的函数在同一行中打印引用变量
- 在 c++ 中将uint8_t数组转换为字符串以在一行中打印
- 是否可以让 Bitset 将位打印到一行?
- 如何避免在同一行上进行这种打印?
- C++控制台打印在同一行上,带回车符
- 如何在C++的一行上打印一定数量的值?
- 为什么仅在CSV文件中打印第一行
- c++ 在同一行上打印
- cout 用于仅打印最后一行的 2D 字符串矢量
- 打印一行 2D 字符数组 (C++)
- 如何在C++的下一行打印我的名字
- 需要帮助在同一行打印不带空格的序列
- 最后一行打印两次(C++)
- 说明:如何使用同一行打印文本后删除前一行-