栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C# > C#教程

c++换行符知识点总结

C#教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

c++换行符知识点总结

c++换行符有哪些

n 换行,光标移到下一行的开头;

endl,把缓冲槽的内容输出到控制台;

r 回车,光标移到当前行的开头,不会换到下一行,如果接着输出的话,本行以前的内容会被逐一覆盖;

#include 
using namespace std;  
int main() 
{ 
  cout << "this is the first linen"; 
  cout << "this is the second liner"; 
  cout << "this is the third linen"; 
  cout << "this is the fouth liner"; 
  cout << "this is the fifth linen"; 
  cout<<"First"<<"n"<<"Second"<

结果:

this is the first line
this is the third linee
this is the fifth line
First
Second
Second23
这是换
行符
Presss any key to continue

内容补充:

关于遇到的问题实例:

遇到r获取n的时候,替换为.

#include
#include
  
int main(int argc, char *argv[])
{
  char str[128];
  while (fgets(str, 127, stdin)) {
    char *tmp = NULL;
    //去掉换行符
    if (tmp = strstr(str, "n"))
      *tmp = '';
    //去掉回车符
    if (tmp = strstr(str, "r"))
      *tmp = '';
    printf("---%s---n", str);
  }
  return 0;
}

到此这篇关于c++换行符知识点总结的文章就介绍到这了,更多相关c++换行符有哪些内容请搜索考高分网以前的文章或继续浏览下面的相关文章希望大家以后多多支持考高分网!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/122231.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号