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); }
Notes
* 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