下面是我的代码
#include <stdio.h>
#include <string.h>
#include <iostream>
int main()
{
std::string data;
data = "hello world";
char string[] = new char [data.length()+1];;
strcpy(string, data.c_str());
}
Run Code Online (Sandbox Code Playgroud)
我收到了一个错误..
file.cpp: In function ‘int main()’:
file.cpp:14:46: error: initializer fails to determine size of ‘string’
Run Code Online (Sandbox Code Playgroud)
我应该怎么做,因为我想将字符串数据的内容复制到char string []
谢谢你的帮助.