Question Description
1. What's cc? (Steps and what does each step do)2. Given a C program, which is run as a.out this is a test int g; int h = 1; main(int argc, char *argv[]) | int A( int x, ......) { | { int a,b,c; | int u,v; a = 2; | b = 3; | HERE: c = A(a,b,"hello"); | } | } (1). Complete the function heading of A(....) (2). Which variables are global? which are local? (3). Which variables are in a.out? (4). Execution is at HERE: DRAW A DIAGRAM TO Show the stack contents from HERE to main()'s argc and argv.3.Given: printu(unsigned int x), which prints an UNSIGNED integer. Write C code to print a SIGNED integer (which may be negative).4. Assignment #2: YOUR printf(char *fmt, ...) is written as { char *cp; int *ip; .......... } which may be called as printf("abc %c xyz %s any %d thing %xn", a,b,c,d);(1). Write C code to let cp point to the fmt string _____________(2). Write C code to let ip point to the first parameter a _______________(3). HOW do you print each of the items a,b,c,d?
Notes: List Processing and LAB #2
5. Write C statements for a struct containing name : an array of 32 chars key : an integer child : pointer to the first child node sibling : pointer to the next sibling node parent : pointer to the parent nodeA tree is implemented as a BINARY tree by the child and sibling pointers.Assume: struct node *p points at a node A. Write C code to print all children of A. struct node *q points at a new node. Write C code to add q as a child of A.Given: 0 1 2 3 4 5 6 7 int (*fptr[ ])(char *) = {menu, mkdir,rmdir,ls, cd, pwd, creat, rm};Write C code to call the function create(char *pathname)Notes: Process Management in UnixLAB3 : Sh Simulator
6. Given: PATH=/bin:/usr/bin: .... :/usr/locl/bin:./ Write C code to tokenize PATH into separate dir strings7. what does int pid = fork() do? after fork(); HOW TO TELL whether it's the parent or the child executing? What does int wait(int *status) do? What does int r = execve("pathname", argv, env); do? How does the system find pathname?__________________________________ Assume the Linux cat is in /bin directory. When running YOUR sh with cat file1 file2 file3 > outfile 8. Write C code to do output redirection > For the above commnad line cat file1 file2 fie3 > outfile: Draw a diagram to show exactly what's YOUR myargv in the r = execve("/bin/cat", myargv, env) call?_________________________ What's the value of r? ____________9. Write C code to do pipe in the command line cat filename | grep line10. Relationship betwee open, close, read write fopen fclose fread fwrite11. Given: struct stat myst. myst.st_mode, myst.st_atime Write C code to get information of a filename: Write C code to determine whether filename is a REGular file or a DIRectory. Write C code to test whether the file is Writeable by Others:____________________________ Readable by Others:____________________________ Write C code to print the file's access time in CALENDAR form.12. Write C code to print the names of all entries in the current directory.13. Fill in blanks for OPEN a file for read mode: _______ fd = open("file", _______); _______ fp = fopen("file", _______); char buf[4096];(a). Write C code to read 4K bytes into buf[] using fd: ______________________(b). Write C code to read 4K bytes into buf[] using fp: ______________________Which of (a) and (b) is faster? WHY? _________________________________________ 14. Use system calls to display the contents of a file:______________________ use Library I/O functions to dispaly the contents of a file:_____________ 15. Given: cpf2f(char *f1, char *f2) copies REG file f1 to REG file f2. Write C code to copy a REG file /a/b/c into a DIRectory /x/y/z ___________
16. Write C code to test whether /a/b/c and /x/y/z are the SAME file:_________
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.