[Previous Homework] [Next Homework]

hw18 - Strings 1


Create an interactive program that gets a person’s first name and displays it, gets the last name and displays it. Next, put the two names together to make the whole name and display it.

  • Include the string.h library
  • Define the lengths of the 3 strings you will be using
  • In main()
    • Declare 3 strings
    • Prompt the user for the first name
    • Use fgets() to read the string in from the user
    • Echo the first name back to the user
    • Do the same for the last name
    • Use strncat() to combine the first and last names
    • Display the whole name back to the user


From Linux on the GL machine:
  • Compile the program:
    gcc -o string1 string1.c

  • Run the program to make sure it works:
    ./string1

  • Use the SUBMIT utility turn in the homework.
    submit cs104_grasso hw18 string1.c string1


Reference Programs :



Make sure that you follow all the coding standards