New version page

UConn CSE 2102 - Lab #3

Documents in this Course
Load more

Previewing page 1


Unformatted text preview:

CSE 3100 Systems Programming Fall 2018Lab #3Welcome to Lab 3! This lab assignment is due 36 hours after your lab session starts. For example,if your lab session starts at 8am on Friday, the assignment is due at 8pm on Saturday.Read each question carefully before beginning work. Start by executing git pull inside your Git repos-itory on the virtual machine. This will create a directory called lab3 which includes code provided for thislab.Note that a Makefile is provided. Please study the new features introduced in the file.Do all your work inside the lab3 directory. Remember to add, commit, and push when you completeyour work. Add ONLY *.c, and ex1-readme to the git repo. Do not add .o files or executables.Part 1: valgrind. Use gdb and valgrind to find and correct all of the bugs in squares.c. You may needto look at the man pages for any library functions used in the code (e.g., atoi()) to understand their functionand to ensure they are being used correctly. Describe all of the bugs you identify in a file called ex1-readmein the lab3 directory. Completely rewriting the program will not be considered a correct solution.Part 2: argvcat. argvcat is a program that concatenates all the arguments in argv and prints out theconcatenated strings. A template is provided in argvcat.c.Your first job is to complete the function my strcat(), which has the following prototype:char ∗ my strcat ( char ∗ s1 , char ∗ s2 ) ;The function takes two strings, s1 and s2, as parameters and returns a new string that is the concatenationof s1 and s2. The memory space allocated for storing the return string should be dynamically allocatedfrom the heap. You should allocate the least amount of space that can still hold the result. Your code shouldnot change the strings s1 and s2. For this part you may use the provided function my strlen() to get thelength of strings, and the standard library functions malloc, calloc, realloc, free and printf to managedynamic memory allocation/deallocation and print the result. No other C standard library functions areallowed.After you implement the function my strcat() correctly, your code should work as in the sample runslisted below:$./argvcat./argvcat$./argvcat a 1 b 2 234./argvcata1b2234$./argvcat 1 a ’’ ’#.’ and more arguments./argvcat1a#.andmoreargumentsYou second job is to fix all memory leaks in the code. You just learned valgrind,


View Full Document
Loading Unlocking...
Login

Join to view Lab #3 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab #3 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?