svn co svn://bits.cs.uic.edu/cs385s12/students/YOURID --username YOURID
then copy the template for homework 1 to your submission directory, and change to this directory to start working on the programming assignment:
cd YOURID
svn cp svn://bits.cs.uic.edu/cs385s12/notes/homeworks/hw1 .
cd hw1
Here are additional instructions on using svn. When you are done with the assignment, all required files should be committed to the repository.
If you have added any files (such as the screenshot), you need to first add this for svn tracking thus:
svn add THEFILE
files that aren't added with an explicit "add" are not managed by svn, and will not be "turned in". Then, to commit a version, do
svn commit -m "An short but informative description of this revision"
Note that you can commit any number of revisions, only the most recent one before the submission deadline will be used for grading. To check the status of your files, use
svn status
the letter in the left column indicates whether a file is being managed, and if so what it's current status is (updated in the repository, updated on your current machine, just added, etc).
TURN-IN REQUIREMENT: When you're done with the homework, make sure you did it right by following the instructions in the last section below.
typedef struct { int identifier; char grade; char name[30]; } Student;NOTE: For this homework only, DO NOT use any built-in functions like: strlen, memcpy, strcpy, sprintf, sscanf etc. except where noted.
printStudent(Student s)
. Using printf, write out the entire structure out byte by byte in hexadecimal format. Next, write to the screen each field of the Student structure in the format described below.
Example usage:
Student st = {1, 'A', "Dennis Ritchie"}; printStudent(st);example output from hw1i2a:
01 00 00 00 41 44 65 6e 6e 69 73 20 52 69 74 63 68 69 65 00 00 00 00 00 00 00 00 00 ... ID: 1 Name: Dennis Ritchie Grade: A
Original record: 01 00 00 00 41 44 65 6e 6e 69 73 20 52 69 74 63 68 69 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ID: 1 Name: Dennis Ritchie Grade: A Renaming to "Hu Li" 01 00 00 00 41 48 75 20 4c 69 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ID: 1 Name: Hu Li Grade: A Renaming to "Balakrishnan Radhakrishnan" 01 00 00 00 41 42 61 6c 61 6b 72 69 73 68 6e 61 6e 20 52 61 64 68 61 6b 72 69 73 68 6e 61 6e 00 00 00 00 00 ID: 1 Name: Balakrishnan Radhakrishnan Grade: AHINT: Every C string is (and must be) terminated by a zero byte.
printStudentShort(Student s)
, to print a shorter description of the student. You can expect all student names to be structured have the format " "
.
Example output from hw1i2c:
1. D. Ritchie: A 2. T. Merrifield: B 3. J. Eriksson: C
sortStudentRecords(Student *students, int count)
, which sorts the count
records in the students array by grade, with A first, and F last.
HINT: The list won't be very long, so a simple bubble sort will do just fine.
char char* unsigned char short int unsigned int struct coordinate {int x,y; }; struct pair { struct coordinate from, to; }; union { int a; short b; char c; } enum { ONE=1; TWO=2; THREE=3; }For example, your answer should contain the line:
char 1 4because the size of a char is 1 byte, and the size of a pointer to a char, on a 32-bit machine, is 4 bytes. HINT: You can have gcc help you with this homework. The C operator sizeof(x) returns the size of a variable or type passed to it. For example, sizeof(signed char)==1. Be sure you understand why a certain type has a certain size though. TURN-IN REQUIREMENT: For this assignment, write your answers in a text file called hw1i3.txt.
int i=257; int *ip=&i; main() { char c = (char)i; char *cp = (char*)ip; }what is the assembly code corresponding to the line:
char c = (char)i;what is the assembly code corresponding to the line:
char *cp = (char*)ip;There is a difference in the opcodes used for these two assignments. What is the difference, and how does this difference affect the resulting value in the destination variable? HINT: use gcc -S like we did in class. TURN-IN REQUIREMENT: For this assignment, supply your answers in a text file called hw1i4.txt.
svn co svn://bits.cs.uic.edu/cs385s12/students/YOURID/hw1
once you're satisfied that all your submission files are in the hw1 directory, you can delete this directory: it is forever preserved in the svn. Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu |
WISEST Helping Women Faculty Advance Funded by NSF | ![]() | ![]() |