I wrote a program that prints the homedirectory of a user but it's not working.

Here is my code:

```
#include <stdio.h>
char cmd[256], name[256], homedir[256];
int main()
{
    printf("Username: ");
    fgets(name,256,stdin);
    sprintf(cmd, "grep %s /etc/passwd|awk -F : '{print $6}'", name);
    FILE *fp = popen (cmd, "r");
    if (fp)
    {
        fgets(homedir, sizeof homedir, fp);
        printf("%s %s", name, homedir);
        pclose(fp);
    }
    return 0;
}

```

it prints:

```
Username: 

```

and after I type 'Paul' it prints nothing and I don't know why.