Solution for Exercise 12-10
ex1210
#include <stdio.h> int main() { char firstname[16],lastname[16]; printf("What is your first name? "); fgets(firstname,16,stdin); printf("What is your last name? "); fgets(lastname,16,stdin); printf("Pleased to meet you, %s %s\n",firstname,lastname); return(0); }
Output
What is your first name? Morton
What is your last name? Boop
Please to meet you, Morton
Boop
Notes
* Give yourself a For Dummies bonus point if you set the array size values as a constant.
* Of course, you could adjust the size of the lastname[]
array, assuming that last names could be longer than 15 characters. If you do so, adjust the value for input with the fgets() function on Line 10 to match.
Copyright © 1997-2024 by QPBC.
All rights reserved