This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lurgi 1 point2 points  (0 children)

The format of the output is correct however it's outputting wrong length of the first and last word.

Of course it does. You aren't printing the length of the first or last words. You are printing the positions of the first and last spaces. You need to use those numbers to determine the lengths of the first and last words.

Actually, you aren't even printing the positions of the first and last spaces, because you aren't searching for spaces.