Skip to content
CS480 Notes
Share
Explore
Course Playbook

icon picker
Project files

Last edited 58 days ago by System Writer
Project requirements/assignment page.
In this programming assignment, students need to count the frequency of each alphabet letter (a-z, total 26 case insensitive) and five case special characters (',' '.' ':' ';' '!') in all the .txt files under a given directory.

Assignment

You will be provided a zero.zip which includes the following files:
makefile
count.h
specialcount.c
alphabetcount.c
testalphabetcount.c
testspecialcount.c
README
Your assignment is to write/modify code in the following files
count.h
makefile
alphabetcount.c to count the frequency of alphabet letters; and
specialcount.c to count the frequency of special characters.
README to explain your code and include your test result
Test.log to record your terminal session when testing your final source code just before submission.
result
Note: Feel free to do any change of these files (fill the code, create new functions and etc). You also can create new .h and .c files if needed.
The instructor will use the following files to test your code, so please DON’T modify these two files:
testalphabetcount.c
testspecialcount.c
your program must execute correctly on Edoras machine, the instructor/TA will type the following commands to test your code:
make testalphabet // generate testalphabet executable file
make testspecial // generate testspecial executable file
./testalphabet // run the testalphabet program to count frequency of alphabet letters, the result will be stored in the file result.txt under result folder
./testspecial // run the testspecial program to count frequency of the five special words, the result will be stored in the file specialresult.txt under result folder.

Directions to complete your assignment

Login Edoras machine and create a new folder called programming under your account
Copy zip and data.zip from the shared folder cs480-02 on Edoras server to your newly created programming folder
Unzip the zero.zip and data.zip on edoras using the commands:
unzip zero.zip
unzip

When finished:
Create a new folder named ‘result’ under the programming folder
Modify source files under folder zero to complete this assignment
Test your program to make sure it works correctly.
Re-test your program following the commands provided above and record the terminal session to Test.log
Write README file to explain your code and include your test result
. └── programming ├── data │   ├── input_00.txt │   ├── input_01.txt │   ├── input_02.txt │   ├── input_03.txt │   ├── input_04.txt │   ├── input_05.txt │   ├── input_06.txt │   ├── input_07.txt │   ├── input_08.txt │   ├── input_09.txt │   ├── input_10.txt │   ├── input_11.txt │   ├── input_12.txt │   ├── input_13.txt │   ├── input_14.txt │   ├── input_15.txt │   ├── input_16.txt │   ├── input_17.txt │   ├── input_18.txt │   ├── input_19.txt │   ├── input_20.txt │   ├── input_21.txt │   ├── input_22.txt │   ├── input_23.txt │   ├── input_24.txt │   ├── input_25.txt │   ├── input_26.txt │   ├── input_27.txt │   ├── input_28.txt │   ├── input_29.txt │   └── input_30.txt └── zero ├── alphabetcount.c ├── count.h ├── makefile ├── specialcharcount.c ├── testalphabetcount.c └── testspecialcharcount.c
megaphone

Makefile

# A Makefile for Program 0, CS480

all: testalphabet testspecial

OTHER_ALPHA__OBJS = testalphabetcount.o alphabetcount.o
OTHER_SPECIAL__OBJS = testspecialcharcount.o specialcharcount.o

CC = gcc
CFLAGS = -g -std=c99

testalphabet: ${OTHER_ALPHA__OBJS}
${CC} -o testalphabet ${OTHER_ALPHA__OBJS}


testspecial: ${OTHER_SPECIAL__OBJS}
${CC} -o testspecial ${OTHER_SPECIAL__OBJS}

${OTHER_SPECIAL__OBJS} ${OTHER_SPECIAL__OBJS}:count.h

clean:
rm -f *.o testalphabet testspecial

info

count.h

/* charcount.h - This header file include type definitions (including function prototypes) and macros
used for the programing assignment zero.
*/

#include <stdio.h>

#define ALPHABETSIZE 26 //The total number of alphabetical letter from a - z (case insensitive)
#define SPECIALCHARSIZE 5 // The number of these special characters ',' '.' ';' ':' '!'

void alphabetlettercount(char *path, char *filetowrite, long alphabetfreq[]);
/**
The alphabetlettercount function counts the frequency of each alphabet letter (a-z, case insensitive) in all the .txt files under
directory of the given path and write the results to a file named as filetowrite.
Input:
path - a pointer to a char string [a character array] specifying the path of the directory; and
filetowrite - a pointer to a char string [a character array] specifying the file where results should be written in.
alphabetfreq - a pointer to a long array storing the frequency of each alphabet letter from a - z:
alphabetfreq[0]: the frequency of 'a'
alphabetfreq[1]: the frequency of 'b'
... ...
alphabetfreq[25]:the frequency of 'z'

Output: a new file named as filetowrite with the frequency of each alphabet letter written in
*/

void specialcharcount(char *path, char *filetowrite, long charfreq[]);
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.