This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:spring2016:cprog:projects:sam0 [2016/03/15 12:48] – [Sample execution: encode] wedge | haas:spring2016:cprog:projects:sam0 [2016/03/15 13:04] (current) – [Submission] wedge | ||
---|---|---|---|
Line 35: | Line 35: | ||
The key should be a **signed char**, allowing for a cipher shift of -128 to +127 (your shift can be left or right, depending on the sign of the number). | The key should be a **signed char**, allowing for a cipher shift of -128 to +127 (your shift can be left or right, depending on the sign of the number). | ||
- | The **encode** and **decode** functionality | + | The **encode** and **decode** functionality |
Operating mode will be determined by the program' | Operating mode will be determined by the program' | ||
Line 46: | Line 46: | ||
Your program needs to: | Your program needs to: | ||
* load the provided input (via **stdin**) into an array for processing (you may want to check for an EOF character to terminate input) | * load the provided input (via **stdin**) into an array for processing (you may want to check for an EOF character to terminate input) | ||
- | * you may assume a maximum input size of 4096 bytes | + | * assume a maximum input size of 4096 bytes |
- | * use the **fgetc(3)** function instead of **fscanf(3)** for reading input from STDIN | + | * use the **fgetc(3)** function instead of **fscanf(3)** for reading input from STDIN (do NOT use any **scanf()** or **gets()** related function, **ONLY fgetc(3)**). |
* obtain the signed char key value from the command-line, | * obtain the signed char key value from the command-line, | ||
* if neither command-line nor key file are available, display error and exit | * if neither command-line nor key file are available, display error and exit | ||
Line 53: | Line 53: | ||
* display the resultant string to STDOUT | * display the resultant string to STDOUT | ||
* the cipher should work only on upper and lowercase letters of the alphabet. Any punctuation, | * the cipher should work only on upper and lowercase letters of the alphabet. Any punctuation, | ||
+ | * the encoding and decoding functionality needs to occur within declared/ | ||
+ | * As they will be performing operations on your array filled with the input data, you also need to make productive use of loops. | ||
+ | * all data needed by the function needs to be passed in by parameter! No global variables. | ||
+ | * The functions should return an integer containing the exact count of non-letters encountered (and therefore left unmodified from input to output). Your **main()** function needs to return this value when complete. | ||
+ | Your program should be a "one shot". It should only perform its intended operation and exit. No prompting for encode/ | ||
+ | |||
+ | When compiling, an additional constraint is added: compile with the **-Wall** flag. | ||
====Sample execution: encode==== | ====Sample execution: encode==== | ||
Via positive command-line key: | Via positive command-line key: | ||
Line 59: | Line 66: | ||
<cli> | <cli> | ||
lab46: | lab46: | ||
- | hello | + | "hello"!! |
- | jgnnq | + | "jgnnq"!! |
^D | ^D | ||
lab46: | lab46: | ||
Line 71: | Line 78: | ||
<cli> | <cli> | ||
lab46: | lab46: | ||
- | hello there | + | hello, there... |
- | ebiil qebob | + | ebiil, qebob... |
^D | ^D | ||
lab46: | lab46: | ||
</ | </ | ||
- | Without command-line nor cipher.key file: | + | //Without// command-line |
<cli> | <cli> | ||
Line 120: | Line 127: | ||
<cli> | <cli> | ||
lab46: | lab46: | ||
- | jgnnq | + | "jgnnq" |
- | hello | + | "hello"!! |
^D | ^D | ||
lab46: | lab46: | ||
</ | </ | ||
- | You can also save typing, by providing your input via a here string (also a nice way to check for EOF): | + | You can also save typing, by providing your input via a //here string// (also a nice way to check for EOF): |
<cli> | <cli> | ||
- | lab46: | + | lab46: |
- | hello | + | hello. |
lab46: | lab46: | ||
</ | </ | ||
Line 137: | Line 144: | ||
* Code must compile cleanly (no warnings or errors) | * Code must compile cleanly (no warnings or errors) | ||
+ | * Use the **-Wall** flag when compiling. | ||
* Output must be correct, and resemble the form given in the sample output above. | * Output must be correct, and resemble the form given in the sample output above. | ||
* Code must be nicely and consistently indented (you may use the **indent** tool) | * Code must be nicely and consistently indented (you may use the **indent** tool) |