K, so I'm trying to put a char array into a pointer. Maybe this doesn't make much sene, but yea. The following is bad code, I know that it is, but help me out.
Code:
char* ptr;
char word[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int count = 0;
ptr = malloc(sizeof(char) * strlen(word) +1);
if (ptr == NULL)
printf("err");
else
{
//How do I copy over the char array into the pointer? This is wrong...
for (count=0; count<strlen(word); count++)
strcat(ptr, word[count]);
printf("%s\n", ptr); //this is wrong
free(ptr);
}