Question: Write a program that performs string processing on all strings. NOTE: You may NOT use the standard library functions found in . Also, you must
Write a program that performs string processing on all strings. NOTE: You may NOT
use the standard library functions found in Also, you must use only pointer notation and pointer arithmetic, where appropriate! You may NOT use array notation! Your program should define the following functions:
pts char myfgets char s int n FILE stream Reads at most one less than the number of characters specified by n into the array pointed to by s from the input pointed to by stream. No more characters are read after a newline is encountered or end of file is encountered. The newline if encountered is stored by the array pointed to by s A null character is appended to the end of string s If the function is successful in reading characters into s then s is returned; otherwise a NULL pointer is returned.
pts int myfputs const char s FILE stream Writes s to the output specified by stream. If the function is successful, then it returns the number of characters written to the output; otherwise it returns MYEOF ie for cases where stream does not point any where yet Make sure you #define MYEOF as
pts int myfgetc FILE stream Reads the next character from the input pointed to by stream. If the input is at the end of file or a processing error occurs return MYEOF; otherwise return the integer representation of the character read.
pts int myfputc int c FILE stream Writes the character c converted to a character to the output specified by stream. If the write is successful the ascii value of the character is returned; otherwise MYEOF is returned.
pts char mygets char s Reads characters from stdin into the array pointed to by s until a newline is encountered. The newline character is NOT kept at the end of the array pointed to by s A null character is written to the end of string s The function returns s
pts int myputs const char s Writes the string pointed to by s to stdout. The function appends a newline to the output. The function returns the number of characters written to the output.
pts int mygetchar void Returns the ascii value of the next character read from stdin.
pts int myputchar int c The function writes character c to stdout. The character c is returned.
pts char mystrcpy char destination const char source Copies all characters in the array pointed to by source into the array pointed to by destination. The null character is also copied. The function returns destination.
pts char mystrncpy char destination, const char source int n Copies no more than n characters from the string pointed to by source into the array pointed to by destination. The function does not copy any characters past a null character. If the string pointed to by source is less than n characters, null characters are appended to the end of the array pointed to by destination until n characters have been written.
pts char mystrcat char destination const char source This function appends a copy of the string pointed to by source including the null character to the end of the string pointed to by destination. The append overwrites the null character at the end of destination. The string pointed to by destination is returned.
pts char mystrncat char destination const char source int n This function appends no more than n characters from the string pointed to by source to the end of the array pointed to by destination. The null character is appended to the end of the result. The destination pointer is returned.
pts int mystrcmp const char s const char s This function compares the string pointed to by s to the string pointed to by s If the string pointed to by s comes before the string pointed to by s in dictionary ordering, then is returned. If the string pointed to by s is the same as the string pointed to by s then is returned the compare function is case sensitive Otherwise is returned.
pts int mystrncmp const char s const char s int n This function compares no more than n characters characters following a null character are not compared from the string pointed to by s to the string pointed to by s If the string pointed to by s comes before the string pointed to by s in dictionary ordering, then is returned. If the string pointed to by s is the same as the string pointed to by s then is returned the compare function is case sensitive Otherwise is returned.
pts int mystrlen const char s This function returns the length of the string pointed to by s The computation of length does NOT include the null character.
pts A main function that tests each of the above implemented functions. You decide how to test your program, making sure to develop good test cases. You will be graded in part on the quality of your test cases, that is the extent to which they cover the possible range of inputs.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
