One final caveat-- we also need to handle spaces, but that's easy to accomplish by skipping that iteration.

1if (curr == ' ') {
2    continue;
3}