小编zhq*_*907的帖子

在cout <<"hello"<< endl中删除endl后,我的C++程序停止工作

这是我的代码.这段代码运行良好.但是当我在"cout <<"Hello world中删除"endl"时!"<< endl;",它无法运行.这是我在删除endl时得到的

#include <iostream>
#include <cstring>

using namespace std;
int main()
{
    char * name;
    char * n = "aaaa";
    strcpy(name, n);
    cout << name;
    cout << "Hello world!" << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

以下是删除endl的代码.

#include <iostream>
#include <cstring>

using namespace std;
int main()
{
    char * name;
    char * n = "aaaa";
    strcpy(name, n);
    cout << name;
    cout << "Hello world!";
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
176
查看次数

标签 统计

c++ ×1