how to make a palindrome using c++
this is in c language #include<stdio.h> #include<conio.h> #include<string.h> main() { char a[100], b[100]; printf("Enter the string to check if it is a palindrome\n"); gets(a); strcpy(b,a); strrev(b); if( strcmp(a,b) == 0 ) printf("Entered string is a palindrome.\n"); else printf("Entered string is not a pailndrome.\n"); getch(); return 0; }
what is the function of strcmp, strrev..?
strcmp (char* str1, char *str2) ---- compares the two string str1, str2 if str1 and str2 are equal, it returns 0, otherwise the difference between the last unequal character of the str1, str2 ===== like *str2 - *str1 strrev(char* str) ---- reverses the presented string (in place) and returns the reversed string
thanks..but is your programme using c++?
the prog is by shopaps....not me... but it seems to be in C but will work in both C and C++ without modification
owh ok thanks..^^
Join our real-time social learning platform and learn together with your friends!