rendered paste body#include <iostream>using namespace std;/*int iMyStricmpUpper(s1,s2)Returns the same value as stricmp unless one of the values is uppercase in which condition the uppercase value precedes.*/int mystricmp(char *s1,char *s2){ int r = 0; while (*s1 == *s2++) if (*s1++ == 0) return (0); if(*s1 > 64 && *s1 < 91) { //if both are the same letter, upper precedes if( ((unsigned char)(*s1 + 32) - *(unsigned char *)(s2-1)) == 0 ) { r = ((unsigned char)((*s1 + 32) - *(unsigned char *)--s2)-1); //limit return value to 1, -1, or 0 if(r > 0) return 1; if(r < 0) return -1; return 0; } //figure precedence alphabetically regardless of case r = ((unsigned char)(*s1 + 32) - *(unsigned char *)--s2); //limit return value to 1, -1, or 0 if(r > 0) return 1; if(r < 0) return -1; return 0; } if(*(s2-1) > 64 && *(s2-1) < 91) { //if both are the same letter, upper precedes if( ((*(unsigned char *)(s2-1) + 32) - (unsigned char)(*s1)) == 0 ) { r = (*(unsigned char *)s1 - (unsigned char)(*(--s2)+31)); //limit return value to 1, -1, or 0 if(r > 0) return 1; if(r < 0) return -1; return 0; } //figure precedence alphabetically regardless of case r = (*(unsigned char *)s1 - (unsigned char)(*(--s2)+32)); //limit return value to 1, -1, or 0 if(r > 0) return 1; if(r < 0) return -1; return 0; } //returns value based on ascii precedence r = (*(unsigned char *)s1 - *(unsigned char *)--s2); //limit return value to 1, -1, or 0 if(r > 0) return 1; if(r < 0) return -1; return 0;}/*int iMyStrcmpUpper(s1,s2)Returns the same value as strcmp unless one of the values is uppercase in which case both are considered equal.*/int mystrcmp(char *s1,char *s2){ int r = 0; while (*s1 == *s2++) if (*s1++ == 0) return (0); if(*s1 > 64 && *s1 < 91) { //disregard case r = ((unsigned char)(*s1 + 32) - *(unsigned char *)--s2); //limit return value to 1, -1, or 0 if(r > 0) return 1; if(r < 0) return -1; return 0; } if(*(s2-1) > 64 && *(s2-1) < 91) { //disregard case r = (*(unsigned char *)s1 - (unsigned char)(*(--s2)+32)); //limit return value to 1, -1, or 0 if(r > 0) return 1; if(r < 0) return -1; return 0; } //return value based on ascii precedence r = (*(unsigned char *)s1 - *(unsigned char *)--s2); //limit return value to 1, -1, or 0 if(r > 0) return 1; if(r < 0) return -1; return 0;}int main(){ char string1[127], string2[127]; cout << "Compare: Program to aphebeticly compare two strings.\n" << "\nEnter first string:"; cin >> string1; cout << "\nEnter second string:"; cin >> string2; cout << "\nmystricmp returned " << mystricmp(string1,string2) << "\n"; cout << "\nmystrcmp returned " << mystrcmp(string1,string2) << "\n"; cout << "\nstrcmp returned " << strcmp(string1,string2) << "\n"; if( mystricmp(string1,string2) < 0 ) cout << "\n" << string1 << "\n" << string2 << "\n"; if( mystricmp(string1,string2) > 0 ) cout << "\n" << string2 << "\n" << string1 << "\n"; if( mystricmp(string1,string2) == 0 ) cout << "\nThe two strings are the same.\n"; return 0;}