Starting from:

$25

Project 8 Enter the name of a file

Project 8, Program Design
Write a program that prompts the user to enter the name of a file for the content to be
shifted:
Enter the file name: jennys_message.txt
Enter shift amount (1-25): 6
Output file name: jennys_message.txt.sft
1. The program reads the content of the file and shifts the content by the shift amount,
then writes the shifted message to a file with the same name but an added extension
of .sft. In this example, the original file name is jennys_message.txt, so the
shifted message will be stored in a file named jennys_message.txt.sft. There is
no limt on the size of the file to be shifted or on the length of each line in the file. Assume
the file name is no more than 100 characters.
2. The program should include the following function:
void shift(char *message, int shift_amount);
The function expects message to point to a string containing the message to be shifted;
shift_amount represents the amount by which each letter in the message to be shifted.
Lower-case letters remain lower-case when shifted, and upper-case remain upper-case.
For example, if the message is “Go ahead, make my day.”, and
shift_amount is 3, the function will modify message to “Jr dkhdg,
pdnh pb gdb.” If the message is “Jr dkhdg, pdnh pb gdb.”, and
shift_amount is 23, the function will modify message to “Go ahead,
make my day.”.
Hint: To handle the wrap-around problem, use the % operator. For example, ‘X’ shifted
by 4 is ‘B’.
Before you submit:
1. Compile with –Wall. Be sure it compiles on circe with no errors and no warnings.
gcc –Wall file_shift.c
2. Be sure your Unix source file is read & write protected. Change Unix file permission
on Unix:
chmod 600 file_shift.c
3. Test your program with the shell scripts on Unix:
chmod +x try_shift
./try_shift
Total points: 100
1. A program that does not compile will result in a zero.
2. Runtime error and compilation warning 5%
3. Commenting and style 15%
4. Functionality 80%
Programming Style Guidelines
The major purpose of programming style guidelines is to make programs easy to read and
understand. Good programming style helps make it possible for a person knowledgeable
in the application area to quickly read a program and understand how it works.
1. Your program should begin with a comment that briefly summarizes what it does.
This comment should also include your name.
2. In most cases, a function should have a brief comment above its definition
describing what it does. Other than that, comments should be written only needed
in order for a reader to understand what is happening.
3. Information to include in the comment for a function: name of the function,
purpose of the function, meaning of each parameter, description of return value (if
any), description of side effects (if any, such as modifying external variables)
4. Variable names and function names should be sufficiently descriptive that a
knowledgeable reader can easily understand what the variable means and what the
function does. If this is not possible, comments should be added to make the
meaning clear.
5. Use consistent indentation to emphasize block structure.
6. Full line comments inside function bodies should conform to the indentation of
the code where they appear.
7. Macro definitions (#define) should be used for defining symbolic names for
numeric constants. For example: #define PI 3.141592
8. Use names of moderate length for variables. Most names should be between 2
and 12 letters long.
9. Use underscores to make compound names easier to read: tot_vol or
total_volumn is clearer than totalvolumn.

More products