Q1. Running bug3 produced the following error: segmentation fault (core dumped)
There is a new executable file called bug3 also recently modified a file called core.
Q2.
#1 0x00000000004009ad in inTable ()
#2 0x0000000000400920 in main ()
Q3.
bug3.c error:
Segmentation fault (core dumped)
Fixed the bug by incrementing numlines after the pointer is returned by strdup( buff );, this was causing the error by trying read and write to memory allocation that didnt exist.
st[ numLines ] = strdup( buff );
++numLines;
increment after allocation.
-----------
quicksortBug.c error:
undefined reference to `main'
Fixed. Did not include brackets for for statement, which are needed in c
Q4. Compiler cannot catch this error because it is not a syntax error. The user forgot to put brackets on for loop, which will only run the first line below the for loop. The compiler does not know that you wanter several lines. You can see this in the stack because the same value is repeated over and over again.
Q5. Using qsort to sort integers and accidentally pass the string comparison function will cause error. The string comparison cannot tell the difference between integer values.