Programming string parser function to find ith space character

Hello,

I am still trying to become familiar with the programming language. I am working on a project to code a parser function that will go through a given character array and find the ith space character, then output the position of this space. If the value of i is larger than the number of spaces in the character array, it should output -1. I am running into trouble and would appreciate any help.

void setup() {
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Char sentence = "This is a sentence.";
  int i = 2;
  int pointer;
  pointer = findspace(sentence, i);
  Serial.print(pointer);
}



int findspace(Char testsentence[], int counti) {
  
  int spacecounter = 0;
  int strlength = testsentence.length();
  int ithspace;
  
  for (ik = 0; ik <= strlength; ik++) {
    if (isSpace(testsentence[ik]))
       spacecounter++;
    if (spacecounter = counti)
       ithspace = ik;
}

if (i > spacecounter)
  ithspace = -1;

return ithspace;
}

When I run this I get an error message on the int strlength = testsentence.length(); line that says "request for member 'length' in 'testsentence', which is of non-class type 'char*'". Not sure how to proceed. Any help would be appreciated!

Made this change and the error message went away, but now the serial monitor just displays 19 every millisecond, which I assume is just the length of the character array. How can I get this to work right?

void setup() {
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  char sentence[] = "This is a sentence.";
  int i = 2;
  int pointer;
  pointer = findspace(sentence, i);
  Serial.println(pointer);
}



int findspace(char testsentence[], int counti) {
  
  int spacecounter = 0;
  int strlength = strlen(testsentence);
  int ithspace;
  int ik;
  
  for (ik = 0; ik <= strlength; ik++) {
    if (isSpace(testsentence[ik]))
       spacecounter++;
    if (spacecounter = counti)
       ithspace = ik;
}

if (counti > spacecounter)
  ithspace = -1;

return ithspace;
}

For starters, this is an assignment statement, not a comparison statement.

if (spacecounter = counti)

Research '=' operator vs. '==' operator.