/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * STRINGS 2 WHOLENAME.C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include #include #define FIRST_SIZE 100+1 #define LAST_SIZE 100+1 #define WHOLE_SIZE FIRST_SIZE+LAST_SIZE+1 void getNames(char *firstName, char *lastName); char *makeWholeName(char *firstName, char *lastName, char *wholeName); int main() { char wholeName[FIRST_SIZE]; char firstName[LAST_SIZE]; char lastName[WHOLE_SIZE]; getNames(firstName,lastName); makeWholeName(firstName, lastName, wholeName); printf( "Your whole name is %s. \n", wholeName );fflush(stdout); return 0; } void getNames(char *firstName, char *lastName) { char *newline; printf("Please enter your first name \n");fflush(stdout); fgets ( firstName, FIRST_SIZE, stdin ); printf( "Your first name is %s. \n", firstName );fflush(stdout); firstName[0] = toupper(firstName[0]); newline = strchr(firstName,'\n'); *newline = '\0'; printf("Please enter your last name \n");fflush(stdout); fgets ( lastName, LAST_SIZE, stdin ); printf( "Your last name is %s. \n", lastName );fflush(stdout); lastName[0] = toupper(lastName[0]); newline = strchr(lastName,'\n'); *newline = '\0'; } char *makeWholeName(char *firstName, char *lastName, char *wholeName) { wholeName[0] = '\0'; strncat(wholeName,firstName, FIRST_SIZE); strcat(wholeName," "); strncat(wholeName,lastName, LAST_SIZE); return wholeName; }