第29336题 单选题
关于C++中字符数组内存分配与相关操作的说法,下列选项正确的是?

已知如下C++代码片段:

#include <iostream>
#include <cstring>
using namespace std;

int main() {
    char arr[] = "hello";
    char* ptr = new char[10];
    strcpy(ptr, "world");
    const char* str_literal = "test";
    return 0;
}

请根据代码判断以下说法正确的是:

{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析