Solution for Exercise 13-11
ex1311
#include <stdio.h> #include <string.h> int main() { char first[40]; char last[20]; printf("What is your first name? "); scanf("%s",first); printf("What is your last name? "); scanf("%s",last); strcat(first," "); strcat(first,last); printf("Pleased to meet you, %s!\n",first); return(0); }
Notes
* The only way to solve the puzzle is to use strcat() to tack the extra space onto the first
string before you add on the last
string.
* Even though the space is a single character, it's specified with double quotes to ensure that the compiler treats it as a string (in Line 13).
Copyright © 1997-2024 by QPBC.
All rights reserved