Subject: testing ISYS290-04 process ### TESTIT REVISION 5 DOS ### FILE process.h int process(char* d, char* s); ### FILE bonus.c /* bonus.c - Bonus Assignment for ISYS290-04 - functions for use with one of awkfilt#.c to: File Name : bonus.c Course Number : ISYS 290 04 Student Name : Jason Gradziel Student Number : 826-135-535 Professors Name : Brian Perry Class Name : Wednesday 9:55 - 12:35 Lab Title : ISYS290 BONUS ASSIGNMENT Write and test a function which has the following prototype and specification: int process( char* d, char* s); The purpose of the function is to make corrections to the grammar of the input text, limited to the description below. The function receives text in parameter 2 (string s). The text arrives one line at a time. The function examines the text and modifies it, if necessary as described below, and moves the output to parameter 1 (string d). The output (string d) text should be a modified to ensure that the first word of each sentence starts with an upper case letter, followed by lowercase letters, and that all other words consist only of lower case letters. NOTE: The first word received when the program runs will be the start of a new sentence. After that new sentences start with the first word after the period ending the previous sentence (i.e. normal rules of grammar). The function should normally move the output into the string represented by parameter 1 (string d) and return 0. If the function finds two adjacent periods it should treat this as an error. In this case it should write a message in the output (string d) as follows. "ERROR - adjacent periods in text: " followed by the current line of data and should return 1 to indicate the error. The function should never cause the contents of the string passed as parameter 2 to change. ***NOTE*** all the actual output is done by the main() function */ #include #include #include /*--- function prototypes */ int process(char* d, char* s); /* user supplied function */ int split_tokens(char* str, char* delims, int expect, char* tokens[]); int process(char* d, char* s) /* user supplied function */ { int word_count = 0; /* counts # of words */ char* word[12]; /* to store each word */ char temp[81] = ""; /* to hold input s */ int num_count = 0; /* count characters in text */ int flag = 1; /* to check if peroid - 0 if no, 1 if yes */ strcpy(temp, s); /* split up input line into array*/ word_count = split_tokens(temp, " \t", 10, word); /* if source is emtpy */ if (word_count == 0) { strcpy (d, "ERROR - nothing in text: "); strcat (d, s); return 1; } /* if first char is a peroid */ if (word[0][0] == '.') { strcpy (d, "ERROR - first character is a peroid: "); strcat (d, s); return 1; } /* loop through text */ for (num_count=0; num_count int split_tokens ( char *text, char *delims, int max, char *words[]) { static char temp[MAXLEN]; int count = 0; char *p; strcpy (temp, text); p = strtok(temp, delims); words[count] = p; count++; while ( (words[count+1] != NULL) && (count <= max) ) { p = strtok (NULL, delims); words [count] = p; count++; } count = count - 1; return count; } ### FILE process.scr >------test number 1--------- <..: QUESTION <..: to be or not to be. that is the QUESTION. --Expected results? --0 --To be or not to be. That is the question. --to be or not to be. that is the QUESTION. <> >------test number 2--------- <..: QUESTION <..: to be or not to be.. that is the QUESTION. --Expected results? --1 --ERROR - adjacent periods in text: to be or not to be.. that is the QUESTION. --to be or not to be.. that is the QUESTION. <> >------test number 3--------- <..: QUESTION <..: to be or not to be. that is the QUESTION..s --Expected results? --1 --ERROR - adjacent periods in text: to be or not to be. that is the QUESTION..s --to be or not to be. that is the QUESTION..s <> >------test number 4--------- <..: QUESTION <..: this.is. A. TEST. WHOOPEE. --Expected results? --0 --This.Is. A. Test. Whoopee. --this.is. A. TEST. WHOOPEE. <> ### END