I am reading in a string character by character then for each word found(separated by space) counting the length of each word, and finally printing all that information to the screen. 

`Sample run: trickier to master`

```
    n=8, s=[trickier]
    n=2, s=[to]
    n=6, s=[master]
    n=0, s=[]
    n=-1, s=[]

```

This is correct what I get is this:

```
    n=0, s=[]
    n=0, s=[]
    n=8, s=[trickier]
    n=2, s=[to]
    n=0, s=[]
    n=6, s=[master]
    n=0, s=[]
    n=-1, s=[]

```

The problem is the leading spaces in the string I have looked at a lot of examples of how to trim the leading spaces, but I couldn't get anything to work with my current source code.

Code: 

```
#include "getword.h"

int getword(char *w) {
    int iochar;
    int index = 0;
    int numberofchars = 0;

    if (numberofchars == 0 && iochar == '\n') {
        w[index] = '\0';
        iochar = EOF;
        return 0;
    }
    if (iochar == EOF && numberofchars == 0) {
        w[index] = '\0';
        return -1;
    }

    while ((iochar = getchar()) != EOF) {
        if (iochar != ' ' && iochar != '\n') {
            w[index] = iochar;
            index++;
            numberofchars++;
        } else {
            w[index] = '\0';
            if (strcmp(w, "done") == 0) {
                return -1;
            } else {
                return numberofchars;
            }
        }
    } //after while loop
} // end of function

int main() {
    int c;
    char s[STORAGE];

    for (;;) {
        (void)printf("n=%d, s=[%s]\n", c = getword(s), s);
        if (c == -1)
            break;
    }
} 

```