首页 > 技术文章 > C-C++字符输出时遇到字符'\n','\0'区别

iucforever 2016-03-12 10:12 原文

#include "iostream"
#include "stdio.h"
#include "stdio_ext.h"
#include "stdlib.h"
#include "string.h"
using namespace std;
int main(int argc, char const *argv[])
{
    char buf[] = "www\nqqqq";
    char buf1[] = "www\0qqqq";
    cout<<"buf="<<buf<<endl;
    cout<<"-----"<<endl;
    cout<<"buf1="<<buf1<<endl;

    return 0;
}
输出时遇到字符'\n',输出字符会换行
输出时遇到字符'\0',其后字符不会输出

推荐阅读