I've managed to store the article into heap, but what should I do with the dictionary? I tried using strcpy(tempArticle[i], dictionary); but it didn't seem to work? would someone give me a hint as to what to do in the next step?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void spellCheck(char article[], char dictionary[]) {
int len = strlen(article) + 1;
int i;
char* tempArticle;
tempArticle = malloc(len);
if (tempArticle == NULL) {
printf("spellcheck: Memory allocation failed.\n");
return;
}
for(i = 0; i < len; i++)
tempArticle[i] = tolower(article[i]);
i=0;
while (tempArticle[i] != '\0'){
if (tempArticle[i] >= 33 && tempArticle[i] <= 64)
tempArticle[i] = ' ';
i++;
}
strcpy(tempArticle[i], dictionary);
printf("%s", tempArticle);
free(tempArticle);
}