CS157: Intro to C, Part II

Spring 2018

HW 2

CS157 HW2: Digraphs                

Description                

For this assignment, you will write a program called dg.c (a “digraph” is a pair of letters). It will read any number of files, and emit a report about the frequency of letter pairs in the input.                 

Sample Runs                

Here are several sample runs. Your output must match exactly, except that the order of the output lines may vary.                 

    % cat data
    Mama misses
    Papa
    % c11 -Wall dg.c
    % ./a.out 1 999 data
    ma 2
    am 1
    mi 1
    is 1
    ss 1
    se 1
    es 1
    pa 2
    ap 1
    % cat f
    food
    % cat d
    dood
    % ./a.out 1 99 f d
    fo 1
    oo 2
    od 2
    do 1
    % ./a.out 1 99 d f
    do 1
    oo 2
    od 2
    fo 1
    % cat hitch
      Don't
    Panic!
    % ./a.out 1 1000 hitch
    do 1
    on 1
    pa 1
    an 1
    ni 1
    ic 1
    % cat now
    2024-04-20T03:36:16.524287
    % ./a.out 1 1000 now
    % ./a.out 1500 1000000 ~cs157/pub/hamlet.txt
    ha 1891
    at 1523
    er 2105
    in 1951
    th 3947
    he 2991
    an 1995
    nd 1536
    or 1593
    ou 1941
    % ./a.out 1600 2000 ~cs157/pub/hamlet.txt
    ha 1891
    in 1951
    an 1995
    ou 1941

Required Data Structures                

Your program must create an array of this type in main, and use it to hold the data throughout the program:                 

    struct LetterPair {		// Note the capital L & P.
        char first, second;
        int count;
    };

Debugging                

If you encounter “STACK FRAME LINK OVERFLOW”, then try this:

    export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a

Requirements                

How to submit your homework:                

Use web checkin, or:                 

    ~cs157/bin/checkin HW2 dg.c

How to receive negative points:                

Turn in someone else’s work.                 

User: Guest                 

Check: HTML CSS
Edit History Source

Modified: 2018-04-18T14:28                 

Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2018 Colorado State University
CS Building