try this function fgets() .... this gets a string from user........
Look at man pages for this function for extracting tokens from string strtok, strtok_r the sytax is char *strtok(char *str, const char *delim);
Separate names with a comma.