Microsoft Word - A2.docx CIS*2500 Assignment 2: nirvanaG Due Thursday March 3rd 11:59pm Weighting: 9% 1.0 Your Task Congratulations! You have been hired as a developer for this company called...

1 answer below »
to be done in c language and in linux environment.


Microsoft Word - A2.docx CIS*2500 Assignment 2: nirvanaG Due Thursday March 3rd 11:59pm Weighting: 9% 1.0 Your Task Congratulations! You have been hired as a developer for this company called nirvanaG. As the sole software developer of this product, you will create a library of string functions that are customized for this company (note the irony – nirvana is about “no strings attached” J, but this job is about strings all over). The required files that you have to create are: 1. Header file: name it lastnameFirstnameA2.h This file must include all function prototypes, global constants and any struct definitions. 2. Implementation file: name it lastnameFirstnameA2.c This file must include all function definitions. The required functions and their description are given later in this section. You are also free to create helper functions, though if they are used by the assignment functions below, include them in lastnameFirstnameA2.c and lastnameFirstnameA2.h so they are accessible to us during grading. 3. A makefile: Your program will be compiled using a makefile with the following flags: -std=c99 -Wall Do not include a main() function in any of your submission(s)—grading will be based on the specified function definitions. You are still encouraged to make a robust testing file containing a main(). Read Section 2.0.1 for more on what to include and what not to include. 4. Requirement on the folder structure of source, header and executable files – read Section 2.0.2 for details. Note that this is a new requirement (was not required for L1, L2 or A1) These constants must be defined, ideally in lastnameFirstnameA2.h file. • #define MAX_LENGTH 20 This will represent the maximum length of a word. • #define MAX_WORDS 50 This will represent the max. number of words in a string. Prototypes for the six required Functions char * readFile (char * filename); This function takes a filename of a text file as input, opens and reads the contents of the file and returns the contents as a string (char *). Note that you are required to use dynamic allocation, so that the returned string is on a heap. For example, if the input file is test1.txt, then this function returns a char * that holds the following characters (given in red): The red readymade dress was made for you! It was going to be ready tomorrow. What was the colour of the dress? Oh, it was red! You will find this text file (test1.txt) and 2 other test files (test2.txt and test3.txt) in the assignment folder on Courselink. Use them for testing. File test1.txt has 77 characters, test2.txt has 129 characters and test3.txt has 732 characters. char * stretchMe (char * aStringToStretch); This function takes a string as its only parameter. It prompts the user to enter exactly n valid positive integers, where n is the length of aStringToStretch. Entering a 0 or negative is considered invalid. The function then creates a new string that consists of the letters in aStringToStretch (in the same order) – each letter repeated by the number of times indicated by the user for that corresponding position. For example, if the function takes "hello!" as its argument, and the user enters the following 6 values: 1 2 2 3 1 2, then the function creates and returns a stretched string as Heelllllo!! Note that the given string may have digits, alphabets, spaces and special characters such as period, colon, semicolon, question mark, or exclamation mark. The new stretched string must be created on a heap using dynamic memory allocation. int splitMe (char * aStringToSplit, char static2D [MAX_WORDS][MAX_LENGTH]); This function takes a string aStringToSplit, splits it into n words, and stores the words in a static 2D string called static2D. The function returns the total number of words stored in static2D. Note that a word is any sequence of characters separated by one or more spaces or a newline. Special characters such as period, colon, semicolon, question mark, or exclamation mark are considered a part of a word, unless separated by a space. For example, total number of words in "Oh, it was red!" is 4. Similarly, in "Oh, it was red!" is also 4. But the total number of words in "Oh , it was red!" is 5. Similarly, the total number of words in the string read from file test1.txt is 15 and from test2.txt is 26. int shrinkMe (char * aStringToShrink); This function takes a string aStringToShrink, finds all punctuations in the given string and removes them from aStringToShrink. The function also returns the total number of punctuations found and removed. Note that this assignment considers the following as punctuations: period, colon, semicolon, question mark, or exclamation mark For example, if the input string is What was the colour of the dress? Oh, it was red! the function returns 2 and shrinks it to What was the colour of the dress Oh, it was red bool isItAPalindrome (char * aString); This function takes a string aString and returns true if every word in the given string is a palindrome and false otherwise. Ignore all punctuations (period, colon, semicolon, question mark, or exclamation mark), spaces and cases. Note that a word is a palindrome if it reads the same backward or forward. For example, madam is a palindrome. Similarly, mom is a palindrome. If “mom sis madam” is passed as a parameter, then the function returns true (since every word in this string is a palindrome). Similarly, if “mother sister madam” is passed as a parameter, then the function returns false (since every word in this string is not a palindrome). void printSuffixes (char * aString, int whichWord, char * desiredSuffix) This function takes a string as a parameter, finds the word given in position whichWord and prints n number of words on the standard output, where n is the length of the word at position whichWord. Each word printed on the screen starts with a letter in the word at position whichWord and is suffixed by desiredSuffix. For example, if aString is “Now is the winter of our discontent Made glorious summer by this Sun of York.”, whichWord is 8 and desiredSuffix is “otter”, then the words printed are Motter aotter dotter eotter 2.0 Compilation Your program will be compiled using a makefile with the following flags: -std=c99 -Wall As stated above, the file containing your main() will not be submitted. In grading this assignment, we will use our own main() function to facilitate testing. Our main will be contained in a file called ‘main.c’. If you include a main() function in your files, it will not compile when we test, and you will likely get a 0. If you do not plan on implementing every function, stub it out (create the definitions in your lastnameFirstnameA2.c and lastnameFirstnameA2.h files and return a meaningless value if it requires one). Otherwise, your submission will not compile with our grader and you will get a 0. 2.0.1 Files required: • lastnameFirstnameA2.c — your function implementations. You must submit this. • lastnameFirstnameA2.h — your function definitions/prototypes, constants, library imports, student info, and declaration of academic integrity. You must submit this. • main.c — your testing file/driver program used to verify outputs/test your functions. This file would contain a main(). You do not submit this. • Makefile - You must submit this. The main target in your makefile must be called noStringsAttached. Note that your makefile is required to have a target called clean, that allows to remove all object files and the executable file (noStringsAttached). Read section 2.0.2 for more details on makefile. 2.0.2 Required folder structure for this assignment A2 folder tree structure (assume that the current folder is called A2) A2 $ Folder src must contain all your source files (i.e., lastnameFirstnameA2.c). Folder include must contain your header file (i.e., lastnameFirstnameA2.h) Folder bin must contain your executable file (i.e. noStringsAttached) Note that the makefile should be located in the top-level directory (e.g. in folder A2). The commands in makefile must call your source, header and executable files via relative path. For example, the dependencies and commands to compile main.c using the above folder structure will be: main.o: src/main.c include/nirvanaG.h gcc -Wall -std=c99 -c src/main.c Also note that all .o object files are created in the current folder (i.e. in folder A2), whereas the executable is created in folder bin. Remember this when you write the target for clean. 2.0.3 Running Running such a program would be done as follows: ./bin/noStringsAttached For example, if the input text file is text1.txt, then your program will be run as ./bin/noStringsAttached test1.txt 3.0 Testing Even though you won't submit a main.c file, you are still strongly encouraged to test throughout the entirety of the development lifecycle of this program. Refer to A1 for more on testing. src include bin 4.0 Submission You will submit your assignment files (lastnameFirstnameA2.c, makefile, and lastnameFirstnameA2.h) to the submission box for A2 submission folder in GitLab. ************Instructions for Gitlab – Start************** Step 1: Computer setup – this is an optional step. You can avoid this step by connecting to the school server via noMachine or (portkey.socs.uoguelph.ca + linux.socs.uoguelph.ca) - make sure git is installed (https://git-scm.com/downloads) - Mac users can use the terminal mode (I have tested it on my mac) - Windows users can use powershell, WSL (windows subsystem for linux) or git bash. - decide where cis2500 work will go and
Answered 17 days AfterFeb 11, 2022

Answer To: Microsoft Word - A2.docx CIS*2500 Assignment 2: nirvanaG Due Thursday March 3rd 11:59pm Weighting:...

Vaibhav answered on Mar 01 2022
115 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here