Hi!

I am writing a very simple program that turns someone's name (written first name last name) into an email address in the following format ==>> [email protected]. However when I run the program the output is like this
=> first name(except first initial) [email protected].
Below is the code:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>


int main()


{
    char first;
    char ch;



printf("enter your firstname lastname:");


    first  = getchar();

    while( (ch=getchar())!=' ')
        printf("%c", ch);

    while((ch=getchar())==' ')
        ;


    do
    { 
        printf("%c",ch);
    }while((ch=getchar())!='\n');

    printf("_%c",first);
printf("@student.smc.edu\n");

    return 0;

}




And the output:

enter your firstname lastname: lisa smith

[email protected]



It should say [email protected] . Can somebody please help me fix the code, so it prints [email protected] ? Thank you!