I am preparing for my Computer Science practical examination, when I hit this roadblock.
The following C code is to capitalize all the words in a string taken from the user.

```
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main()
{
    char a[20];
    int i;
    printf("Enter a string: ");
    scanf("%[^\n]s",a);

    if(islower(a[0])!=0)
    {
        a[0]=toupper(a[0]);
    }

    for(i=0;i<strlen(a);i++)
        if(a[i]==' ' && isalpha(a[i+1]!=0))
            a[i+1]=toupper(a[i+1]);

    printf("%s\n",a);
    return 0;
}

```

But the above code doesn't perform the task. It takes the input, but gives the same output(the entered string, as is). Also, there are no errors or warnings shown. I am coding in Ubuntu 14.04 using gcc. I don't seem to understand as to why the code doesn't work.