I am trying to copy content from one char array to another char array and below is my code,
char dest[100]; //destination array
char content[100]; //Which will be "11,22,33,44,55" - source array
//Split source array with comma delimiter
char *ch ;
ch = strtok(content, ",");
while (ch != NULL) {
printf("%s\n", ch); //prints each entry seperated by comma
ch = strtok(NULL, " ,");
//Code to copy content to dest ?
}
i want to populate dest char array with below content,
dest[0] = 11 dest[1] = 22 dest[2] = 33 dest[3] = 44 dest[4] = 55
I have tried below with no luck,
memcpy(dest, ch, 1);
strcpy(dest,ch);
How can i do this?
EDIT : The source content is alpha-numerical (e.g) 11,2F,3A,BB,E1 is alos possible
strcpywork? What is the result you get, and what did you expect?strtokin the loop?char dest[100];-->char dest[50][100];..strcpy(dest[index++], ch);char content[100] = "65,66,67,68";anddestarray should then contain"ABCD".