below is my code
#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());
}
I got an error..
file.cpp: In function ‘int main()’:
file.cpp:14:46: error: initializer fails to determine size of ‘string’
What should i do as I want copy the content of string data into char string[]
Thanks for helping.
memcpy()as the length of the string is known unless the string to be copy may contain null characters.