char * to char array

May 10, 2014 at 7:25pm
how to copy content of character pointer to character array in c programming..
May 10, 2014 at 7:29pm
Assuming the array is large enough to contain the entire string, you'd use strcpy:

1
2
3
4
const char* ptr = "Pointer to some string data";
char array[100];  // <- must be large enough to contain the string data

strcpy(array,ptr); // <- copies the string data from ptr to array 
Topic archived. No new replies allowed.