System Level Programming Lab Assignment 10 – Post-Lab


5/5 - (2 votes)

CSC3320 System Level Programming
Lab Assignment 10 – Post-Lab

Purpose: Learn how to use the pointers to represent strings in C.
Part 1:
Write a function about string copy, the strcpy prototype “char* strcpy (char* strDest, const
char* strSrc);”. Here strDest is destination string, strSrc is source string.
1) Write the function strcpy, don’t call C string library.
2) Here strcpy can copy strSrc to strDest, but why we use char* as the return value of strcpy?
Part 2:
Write a program findStr.c that finds the “smallest” and “largest” in a series of words. After the
user enters the words, the program will determine which words would come first and last if the
words were listed in dictionary order. The program must stop accepting input when the user enters
a four-letter word. Assume that no word is more than 20 letters long. An interactive session with
the program might look like this:
Enter word: dog
Enter word: zebra
Enter word: rabbit
Enter word: catfish
Enter word: walrus
Enter word: cat
Enter word: fish
Smallest word: cat
Largest word: zebra
Hint: Use two strings named smallest_word and largest_word to keep track of the “smallest” and
“largest” words entered so far. Each time the user enters a new word, use strcmp to compare it with
smallest_word; if the new word is “smaller”, use strcpy to save it in smallest_word. Do a similar
comparison with largest_word. Use strlen to determine when the user has entered a four-letter
1) Attach the source code of your C program into the answer sheet.
2) Run the C program, attach a screenshot of the output in the answer sheet.
• Please follow the instructions below step by step, and then write a report by
answering the questions and upload the report (named as
Lab10_FirstNameLastName.pdf or Lab10_FirstNameLastName.doc) to Google
Classroom, under the rubric Lab 10 – Post Lab Assignment.
• Upload the C files findStr.c to the folder named “Lab 10 – Post Lab” in Google
• Please add the lab assignment NUMBER and your NAME at the top of your

PlaceholderSystem Level Programming Lab Assignment 10 – Post-Lab
Open chat
Need help?
Can we help?