View difference between Paste ID: Qzf2eC1k and syHZxZpy
SHOW: | | - or go back to the newest paste.
1
/*   Writing own version of the "   strcmp( )   "  library function which is named mystrcmp( )   */    
2
#include<stdio.h>
3
int mystrcmp(char str1[],char str2[]);
4
int main(void)
5
{
6
    char s1[999999];
7
    char s2[999999];
8
    gets(s1);
9
    gets(s2);
10
    int x=mystrcmp(s1,s2);
11
    printf("%d",x);
12
    return 0;
13
}
14
int mystrcmp(char str1[],char str2[])
15
{
16
    int i;
17
    for(i=0;str1[i]!='\0';i++)
18
    {
19
20
    }
21
22
    int j;
23
    for(j=0;str2[j]!='\0';j++)
24
    {
25
26
    }
27
28
    if(i>j)
29
    {
30
        return 1;
31
    }
32
    else if(i<j)
33
    {
34
        return -1;
35
    }
36
    else
37
    {
38
        return 0;
39
    }
40
}