User Tools

Site Tools


haas:fall2015:cprog:projects:cbf0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
haas:fall2015:cprog:projects:cbf0 [2015/11/10 13:16] – [Background] wedgehaas:fall2015:cprog:projects:cbf0 [2015/11/10 13:23] (current) – [Submission] wedge
Line 26: Line 26:
 The computer works in units of **bytes**, which these days means groups of 8-bits. C has the ability to arbitrarily read and write individual bytes of data, and we will want to make use of that to aid us in our current task. The computer works in units of **bytes**, which these days means groups of 8-bits. C has the ability to arbitrarily read and write individual bytes of data, and we will want to make use of that to aid us in our current task.
 =====Task===== =====Task=====
-On lab46, in **/var/public/cprog/spring2015/cbf0/** is a file called **out.file**, a 124284 byte binary file that is essentially a scrambled JPEG file (originally called **cbf0.jpg**).+On lab46, in the **cbf0/** subdirectory of the CPROG Public Directory is a file called **cbf0.file**, a 120480 byte binary file that is essentially a scrambled JPEG file (originally called **cbf0.jpg**).
  
-Your task is to write a C program to unscramble **out.file** and return it to its image-viewable **cbf0.jpg** state.+Your task is to write a C program to unscramble **cbf0.file** and return it to its image-viewable **cbf0.jpg** state.
  
-For those who are in UNIX, you are not allowed to use any of the UNIX tools to accomplish this task: you must write a C program that does all the work.+Regardless of whether or not you are in UNIX, you are not allowed to use any of the UNIX tools to accomplish this task: you must write a C program that does all the work.
  
-The **out.file** data file has been scrambled as follows:+The **cbf0.file** data file has been scrambled as follows:
  
-  * The last twelve consecutive 12 bytes (in incrementing order) of **cbf0.jpg** are the first twelve consecutive bytes of **out.file** +  * The last twelve consecutive 12 bytes (in incrementing order) of **cbf0.jpg** are the first twelve consecutive bytes of **cbf0.file** 
-  * The next previous twelve consecutive 12 bytes (in incrementing order) of **cbf0.jpg** are the next twelve consecutive bytes of **out.file** +  * The next previous twelve consecutive 12 bytes (in incrementing order) of **cbf0.jpg** are the next twelve consecutive bytes of **cbf0.file** 
-  * and so on until the file is "reversed", in units of 12 byte chunks (the individual bytes of the chunks have not had their order changed)+  * and so on until we reach the beginning. In other words, the file's data is "reversed", in units of 12 byte chunks (the individual bytes of the chunks have not had their order changed).
  
 Your task is to write a C program that does the following: Your task is to write a C program that does the following:
  
-  * opens and reads **out.file** +  * opens and reads **cbf0.file** 
-  * caches its entire contents in an array (don't waste space! use appropriately-sized data types) +  * caches its entire contents in an array (don't waste space! use appropriately-sized data types and allocated storage
-  * once loaded into memory, close **out.file** and open a new file for writing+  * once loaded into memory, close **cbf0.file** and open a new file for writing
     * that new file will be called **/home/username/public_html/cbf0.jpg** (where "username" is your lab46 username)     * that new file will be called **/home/username/public_html/cbf0.jpg** (where "username" is your lab46 username)
   * do the necessary processing to unscramble (unreverse) the reversed data, being mindful of those 12 byte chunks, to restore the original **cbf0.jpg** file in its specified location.   * do the necessary processing to unscramble (unreverse) the reversed data, being mindful of those 12 byte chunks, to restore the original **cbf0.jpg** file in its specified location.
Line 54: Line 54:
 Note that the "~" IS very much required. Note that the "~" IS very much required.
  
-If you are successful, the image should render itself in the browser, and you should be able to recognize it (vs. it being unreadable and unrecognizable). The image is intended to be meme-like in original, and hopefully will invoke a mild sense of humor (that of course is optional). +If you are successful, the image should render itself in the browser, and you should be able to recognize it (vs. it being unreadable and unrecognizable). The image is intended to be meme-like, and hopefully will be at least mildly humorous (that of course is optional).
  
 =====Submission===== =====Submission=====
Line 77: Line 76:
  
 <cli> <cli>
-$ submit cprog cbf0 cbf0.c out.file /home/username/public_html/cbf0.jpg+$ submit cprog cbf0 cbf0.c cbf0.file /home/username/public_html/cbf0.jpg
 Submitting cprog project "cbf0": Submitting cprog project "cbf0":
     -> cbf0.c(OK)     -> cbf0.c(OK)
-    -> out.file(OK)+    -> cbf0.file(OK)
     -> /home/username/public_html/cbf0.jpg(OK)     -> /home/username/public_html/cbf0.jpg(OK)
  
haas/fall2015/cprog/projects/cbf0.1447161408.txt.gz · Last modified: 2015/11/10 13:16 by wedge