I'm trying to count spaces using c strings. I can't use std strings. And on the line comparing the two chars I get the error 'invalid conversion from 'char' to 'const char*'.
I understand that I need to compare two const chars* but I'm not sure which one is which. I believe sentence[] is the char and char space[] is const char* is that right? And I need to use some sort of casting to convert the second but I'm not understanding the syntax I guess. Thanks for the help <3
int wordCount(char sentence[])
{
int tally = 0;
char space[2] = " ";
for(int i = 0; i > 256; i++)
{
if (strcmp(sentence[i], space) == 0)
{
tally++
}
}
return tally;
}