Lab 0 - C Primer
Practice with C Programming: This lab serves to reinforce your proficiency in C programming, particularly with pointers, dynamic memory allocation (malloc), and manual memory management (free), which are critical for systems programming and performance-sensitive applications.
Lab Materials
Discussion Videos
Assignment
$ make gcc -Wall -g -I. -ITests -o runTests main.c In file included from Tests/test1.h:4, from main.c:1: ./LinkedList.h:46:21: warning: ‘createNode’ defined but not used [-Wunused-function] 46 | static struct Node* createNode(int data) | ^~~~~~~~~~ Program has been compiled! $./runTests Merge Test Failed: Function returned NULL. Cycle Detection Test Failed: Merged list is NULL. Merge Test Failed: Function returned NULL. Cycle Detection Test Failed: Merged list is NULL. Merge Test Failed: Function returned NULL. Cycle Detection Test Failed: Merged list is NULL. Merge Test Passed: Both lists were empty, and merge returned NULL as expected. Cycle Detection Test Passed: No cycle detected, as expected with empty lists. Merge Test Failed: Function returned NULL. Cycle Detection Test Failed: Merged list is NULL. Merge Test Failed: Function returned NULL. Cycle Detection Test Failed: Merged list is NULL. Merge Test Failed: Function returned NULL. Cycle Detection Test Failed: Merged list is NULL. Merge Test Failed: Function returned NULL. Cycle Detection Test Failed: Merged list is NULL. Merge Test Failed: Function returned NULL. Cycle Detection Test Failed: Merged list is NULL. Merge Test Failed: Function returned NULL. Cycle Detection Test Failed: Merged list is NULL. Total Score: 28/100Your tasks for this lab are as follows:
$ make runTests $ ./runTests Merged List: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> NULL Merge Test Passed. Cycle Detection Test Passed. Merged List: 1 -> 2 -> 3 -> 4 -> 5 -> 7 -> 9 -> NULL Merge Test Passed. Cycle Detection Test Passed. Merged List: 2 -> 4 -> 6 -> NULL Merge Test Passed. Cycle Detection Test Passed. Merge Test Passed: Both lists were empty, and merge returned NULL as expected. Cycle Detection Test Passed: No cycle detected, as expected with empty lists. Merged List: 1 -> 1 -> 3 -> 3 -> 5 -> 5 -> NULL Merge Test Passed. Cycle Detection Test Passed. Merged List: 1 -> 3 -> 5 -> 7 -> NULL Merge Test Passed. Cycle Detection Test Passed. Merged List: 2 -> 2 -> 4 -> 6 -> NULL Merge Test Passed. Cycle Detection Test Passed. Merged List: -10 -> -8 -> -3 -> 2 -> 5 -> 7 -> 20 -> NULL Merge Test Passed. Cycle Detection Test Passed. Merged List: 1 -> 2 -> 3 -> 4 -> 6 -> 7 -> 8 -> NULL Merge Test Passed. Cycle Detection Test Passed. Merged List: 1 -> 2 -> 3 -> 10 -> 20 -> 30 -> NULL Merge Test Passed. Cycle Detection Test Passed. Total Score: 100/100
Evaluation