I think it should changed to

```c++
while (i < charLength && pString.charAt[i] == ' ') {
    ++i;
}
```