This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:fall2015:cprog:projects:cbf0 [2015/11/10 13:16] – [Background] wedge | haas: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 **/ | + | On lab46, in the **cbf0/ |
- | 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 " | + | * and so on until we reach the beginning. In other words, |
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 **/ | * that new file will be called **/ | ||
* 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 " | Note that the " | ||
- | 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 | + | 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 |
=====Submission===== | =====Submission===== | ||
Line 77: | Line 76: | ||
<cli> | <cli> | ||
- | $ submit cprog cbf0 cbf0.c | + | $ submit cprog cbf0 cbf0.c |
Submitting cprog project " | Submitting cprog project " | ||
-> cbf0.c(OK) | -> cbf0.c(OK) | ||
- | -> out.file(OK) | + | -> cbf0.file(OK) |
-> / | -> / | ||