|Marina Barsky 9f6a6b1628 Update 'README.md'||1 year ago|
|.gitignore||1 year ago|
|01.pointers1.c||1 year ago|
|02.pointers2.c||1 year ago|
|03.memory1.c||1 year ago|
|04.memory2.c||1 year ago|
|05.strings1.c||1 year ago|
|06.strings2.c||1 year ago|
|07.structs1.c||1 year ago|
|08.structs2.c||1 year ago|
|09.files1.c||1 year ago|
|10.files2.c||1 year ago|
|11.linkedlists1.c||1 year ago|
|12.linkedlists2.c||1 year ago|
|13.fork1.c||1 year ago|
|14.fork2.c||1 year ago|
|15.signals1.c||1 year ago|
|16.signals2.c||1 year ago|
|17.sorting1.c||1 year ago|
|18.sorting2.c||1 year ago|
|19.bits1.c||1 year ago|
|20.bits2.c||1 year ago|
|LICENSE||1 year ago|
|README.md||1 year ago|
You need to do at least 8⁄20 questions correctly. Out of these questions 3 should be from Strings, Files and Linked Lists - one from each.
Find out (add code to print out) the address of the variable x in foo1, and the variable y in foo2. What do you notice? Can you explain this? Add your explanation directly to this README file:
Find and eliminate all code that generates Segmentation Fault.
Read code in files 03.memory1.c and/or 04.memory2.c.
Then compile code using:
gcc -g -o test [file.c], and run valgrind command to check for memory problems:
Continue fixing the code until no more errors can be identified by valgrind.
valgrind –tool=memcheck ./test
Write a function convert whose first parameter is an array of strings and second parameter is the number of elements in this array.
Your function should return a string that is the reverse of a longest string in the array (any longest will do in the case of a tie) or NULL if the array was empty. You must not change the strings in the array. You may assume all the strings in the array are null-terminated.
Write a function that converts an integer number into a C-string (null-terminated character array) and returns this string. Add each digit to the resulting string separately, do not use
Try to compile and run 07.structs1.c. Fix all errors and memory problems and try again.
Complete the code according to the instructions in file 08.structs2.c.
Write a program last that prints the last n lines of its text input. The input is in a file with the file name specified as a command-line argument. By default n should be 5, but your program should allow an optional argument so that
./last n prints out the last n lines, where n is any integer.
Your program should make the best use of available storage. It cannot load and store the entire file content because the file is presumed to be too big.
Write a C program to count occurrences of a word in file. The word is provided as a command-line argument.
You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1’s digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list.
Write a sortedinsert() function which given a list that is sorted in increasing order, and a single node, inserts the node into the correct sorted position in the list.
Compile and run 12.fork1.c. What is this program doing? If you think that something is wrong with it, fix it.
Answer the following questions related to the program in file 14.fork1.c.
Write a program that prints its process id, and then runs an infinite loop. When the process receives an interrupt signal, it should print «Hello world». After testing that you cannot terminate the program with
Ctrl+C, use process id to hard kill it.
Finish setup of unix socket server in file 16.signals2.c.
Using qsort and function pointers, sort list of persons first by the last name, and then, in case of a tie, by the first name.
Using qsort and function pointers sort an array of points by the euclidean distance from Point(0,0).
Write a C program to input any number from user and find highest order set bit of given number using bitwise operators.
Input: 22 Output: Highest order set bit in 22 is 4.
Write a C program which takes 2 chars as an input, scans their bits from left to right and finds the first position where their bits are different.
Input: 12, 14. Output: The first different bit is at position 6 from the left.