Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Description: A MyString ADT should behave much like the c++ string class. Your i

ID: 3657269 • Letter: D

Question

Description: A MyString ADT should behave much like the c++ string class. Your implementation should use a dynamically allocated char array to hold a character string. If the amount of memory allocated to the array is too small to complete some necessary task your object should automatically double its capacity until it is large enough to complete the task. If you discover that your object is using less than 25% of its capacity your object should shrink to half its capacity until it is using more that 25% of its capacity or to a minimum capacity of 10 bytes. When data is first entered into your object, start the capacity off at the minimum 10 byte level. Assignment: Implement the MyString ADT using a header and implementation file named MyString.h and MyString.c respectively. Make sure to properly test your code on your own by creating a test driver that has at least one function that tests every function created in the MyString ADT. Attributes int length

Explanation / Answer

#include #include main() { char a[100]; int length; printf("Enter a string to calculate it's length "); gets(a); length = strlen(a); printf("Length of entered string is = %d ",length); return 0; } or #include main() { char array[100], *pointer; int length = 0; printf("Enter a string "); gets(array); pointer = array; while(*(pointer+length)) length++; printf("Length of entered string = %d ",length); return 0; } int string_length(char *s) { int c = 0; while(*(s+c)) c++; return c; }