C Project You should assume that no more than 100 80characte
C Project
You should assume that no more than 100 80character chunks will be read (8000 total characters).
 This project will help you with reading in strings from the user, parsing the strings using pointers, and creating copies of strings using pointers
 
 The goal is to grab user input (a lot of user input) 80 characters at a time and parse the data into words and then run some statistics on the words.
 
 To assist, I have some steps that will be good to follow for completing the project
 
 1) Use a buffer to read in NO MORE THAN 80 characters of input from the user.
 2) Break what was read into smaller pieces based on spaces.
 3) For each of the pieces you get from 2 make a copy and have the copy be referenced by a pointer from an array of pointers.
 4) after we get each buffer of 80 characters, do some processing on the words. Keep track of how many words of each length we saw, and calculate the average word length. (these values will be off slightly because we may break a word at the 80 character boundary and we are not worried about fixing that just yet)
 
 The ZyLab has been created for testing/submission purposes https://zybooks.zyante.com/#/zybook/UICCS107TheysFall2016/chapter/7/section/17
  The blackboard link for submission has also been created.
 
 The idea:
 
 Sample User input:
Your code should only read in the first 80 characters, which is
Then break this into smaller pieces
Where each of the words is obtained from a pointer in an array.
 
 
 Then repeat, go get the next 80 characters
break them into smaller pieces
Should have two fixed size arrays, one is an array of pointers, second is array of ints holding number of words in each malloc\'d sentence.
Affter reading in all of the blocks, and creating your data, you should then print out the word length data
 Word length (in characters) and number of occurrences
 1 character word occurred 2 times
 2 character word occurred 6 times
... average word length is __ characters
(max number of characters in a word should be dynamic.)
Solution
#include <stdio.h>
 #include <string.h>
 //Define Arrays fixed size
 #define ARRAY_SIZE 800
int main(int argc, char *argv[])
 {
     //Array of pointers to Words
     char *words[ARRAY_SIZE] = {NULL};
     //Array of Word Sizes
     int lengths[ARRAY_SIZE] ={0};
     //user will enter 100 times
     int max_user_inputs = 1;
     //user will eneter max 80 Characters including spaces
     char data[80];
     //Counter for number of inputs
     int numInputSteps = 0;
     //Counter for Total Words
     int numWords = 0;
    while(numInputSteps < max_user_inputs){
        printf(\"Enter Next data\ \");
        fgets(data, sizeof(data), stdin);
        //get actual length
        size_t len = strlen(data);
        int begin = 0;
        int end = 0;
        int i = 0 ;
        while (i < len) {
            if(data[i] == \' \' || data[i] == \'\ \') {
                words[numWords] = malloc(sizeof(char) * (end-begin));
                strncpy(words[numWords], &data[begin], (end-begin));
                if(begin == 0)
                    lengths[numWords] = (end-begin);
                else
                    lengths[numWords] = (end-begin)-1;
                begin = end;
                numWords++;
            }
           end++;
            i++;
       }
        memset(data,0,80);
        numInputSteps++;
     }
    //Print Number of Words for each character length
     int wordLegnth = 1;
    while(wordLegnth <= 80){
         int wordCount = 0;
        for(int i = 0 ; i < ARRAY_SIZE ; i++){
             if(words[i] != 0x00){
                 if(lengths[i] == wordLegnth){
                     wordCount++;
                 }
             }
             else{
                 break;
             }
         }
         printf(\"%d character word occurred %d times\ \",wordLegnth,wordCount);
         wordLegnth++;
}
    //Average legth caclulation
     int TotalValidWords = 0;
     int totalLength = 0;
     for(int i = 0 ; i < ARRAY_SIZE ; i++){
        if(words[i] != NULL){
            TotalValidWords++;
            totalLength += lengths[i];
        }
     }
     printf(\"Average Length is %f\ \",(totalLength/TotalValidWords));
    return 0;
 }



