Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Writing own version of the " strcmp( ) " library function which is named mystrcmp( ) */
- #include<stdio.h>
- int mystrcmp(char str1[],char str2[]);
- int main(void)
- {
- char s1[999999];
- char s2[999999];
- gets(s1);
- gets(s2);
- int x=mystrcmp(s1,s2);
- printf("%d",x);
- return 0;
- }
- int mystrcmp(char str1[],char str2[])
- {
- int i;
- for(i=0;str1[i]!='\0';i++)
- {
- }
- int j;
- for(j=0;str2[j]!='\0';j++)
- {
- }
- if(i>j)
- {
- return 1;
- }
- else if(i<j)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment