You Will Follow The Same Logic As Lab 7 For Menu Driven Program To Ensure That The User Does Not Enter Wrong Options
You Will Follow The Same Logic As Lab 7 For Menu Driven Program To Ensure That The User Does Not Enter Wrong Options
1. For the lab, you will write a menu drive program that will have the following options
1> Copy a string from source to destination.
2> Compare two strings
3> Concatenate two strings.
4> Check if a string is palindrome
5> Exit
You will follow the same logic as Lab 7 for menu driven program to ensure that the
user does not enter wrong options.
2. Create a separate header file called mystring.h and mystring.c(using Visual Studio). The
header file should contain prototypes and the c file should contain definitions of the
following functions.
Option 1 Behaviour:
1. Prompt the user to enter a string into a character array called “src_string” of size 100 in
main using a function called mygets ()
2. Also declare another array of size 100 called “dst_string”.
3. Call the function mystrcpy to copy the src_string into dst_string.
4. Display both strings using a function called myputs ()
Option 2 Behaviour:
1. Prompt the user to enter a string into src_string using mygets ()
2. Prompt the user to enter a string into dst_string using mygets ()
3. Compare the two strings using a function called mystrcmp () described below. This function
adds to the logic of strcmp () from string.h as described below.
4. Display if the src_string is equal, greater than or less than dst_string. If the strings are not
equal, also display the index where the first mismatch occurs using normal printf statements
Option 3 Behavior:
1. Prompt the user to enter a string into src_string using mygets ()
2. Prompt the user to enter a string into dst_string using mygets()
3. Append src_string to dst_string using a function mystrcat ()
4. Display both src_string and dst_string using myputs ()
Option 4 Behaviour:
1. Prompt the user to enter a string into src_string.
2. Call a function called isPalindrome () to which you will pass src_string. This function should
check if the passes string is a palindrome or not
3. Display if the string is a palindrome or not using either myputs or printf
Palindromes: A palindrome is a string that can be read the same way in either direction
Examples:
# civic
# dad
# hannah
# kayak
# madam