Program Design

0 comments

Write a program to check if an email address read from a file is a UCLA email, an email that contains ucla.edu. The output file should contain all the UCLA email addresses read from the input file. You can assume email addresses in the file are valid email addresses.

Example input/output:

Enter input file:

emails1.txt

Output:

output file name is UCLA_emails1.txt

Technical requirements:

1. Name your program UCLA_emails.c

2. Prompt the user to enter a file name for the input file.

3. The output file name should be the same name but with an added prefix of

UCLA_. For example, if the input file name is emails.txt, the output file name

should be UCLA_emails.txt.

4. Assume the input file name is no more than 100 characters.

5. Read the emails from the file. Email addresses are stored in separate lines.

6. Assume length of email addresses is no more than 2000 characters.

7. The program should include the following function:

int is_UCLA_email(char *email);

The function expects email to point to a string containing an email address. The

function returns 1 if email address contains ucla.edu, and returns 0 otherwise. String

library functions are allowed.

8. In the main function, call is_UCLA_email function and write the email address to the

output file if it is an UCLA email.

##

#. The program should begin with a comment that briefly summarizes what it does.

#. 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.

#. 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)

#. 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.

#. Use consistent indentation to emphasize block structure.

#. Full line comments inside function bodies should conform to the indentation of the code

where they appear.

#. Macro definitions (#define) should be used for defining symbolic names for numeric

constants. For example: #define PI 3.141592

#. Use names of moderate length for variables. Most names should be between

2 and 12 letters long.

#. Use underscores to make compound names easier to read:

tot_vol or total_volumn is clearer than totalvolumn

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}