So I want to pass the double pointer of a character array, but I am getting this error:
"warning: comparison between pointer and integer
if (*(ptr_double+i) != ' ' && *(ptr_double+i+1) == ' ')"
Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void word_counter(char **ptr_double, int len)
{
int i = 0, j = 0, count = 0, word = 0;
for (i = 0; i < len; i++)
{
if (*(ptr_double+i) != ' ' && *(ptr_double+i+1) == ' ')
word = word + 1;
}word++;
printf("The number of words is %d
", word + 1);
}
int main()
{
int len, i;
char sentence[100];
char temp;
char *ptr = sentence, **ptr_double = &ptr;
printf("Enter a sentence
");
fflush(stdin);
gets(*ptr_double);
puts(*ptr_double);
len = strlen(*ptr_double);
word_counter(ptr_double, len);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…