-
cprogramming
-
I need help with an exercise in C. This is what I tried to do, but it doesn't work. int main() { int i, leng; char phrase[DIM], word[DIM], word2[DIM]; printf("Write a sentence\n>>"); fgets(phrase, sizeof(phrase), stdin); printf("Enter the word you want to replace in the sentence\n>> "); fgets(word, sizeof(word), stdin); printf("What do you want to replace it with?\n>> "); fgets(word2, sizeof(word2), stdin); leng = strlen(phrase); for(i = 0; i < leng; i++){ if(phrase[i] == word){ phrase[i] = word2; } } printf("%s", phrase); When I start it, these warnings appear: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] comparison between pointer and integer What I have tried: I tried to use strcmp, but i don't know how to use it with this exercise
asked by pippepappe