forked from vasant-prabhu/Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
passwordchecker
65 lines (57 loc) · 1.28 KB
/
passwordchecker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SIZE 10
int main()
{
char *pass1=(char*)malloc(SIZE);
char *pass2=(char*)malloc(SIZE);
int n1=0,n2=0,m=0,count=0,i=0,j=0;
memset(pass1,0,SIZE);
memset(pass2,0,SIZE);
printf("Size:%d\n",strlen(pass1));
printf("Enter old password\n");
scanf("%s",pass1);
n1=strlen(pass1);
printf("\nLength:%d\n",n1);
if(pass1[n1]== '\0')
printf("YES\n");
printf("you entered:%s\n",pass1);
printf("Enter new pass:\n");
scanf("%s",pass2);
n2=strlen(pass2);
printf("you entered new:%s\n",pass2);
printf("Count->%d\n",count);
while (pass1[i]!='\0')
{
printf("Entered while\n");
if(pass1[i]==pass2[j])
{
printf("equal:i:%d:j:%d\n",i,j);
i++;
j++;
}
else
{
count++;
i++;
j++;
printf("c:%d\n",count);
}
if( pass2[j] =='\0')
{
printf("Breaking c:%d\n",count);
break;
}
}
if(pass2[j]=='\0' && pass1[i]!='\0')
{
count+=n1-i;
}
else if(pass2[j]!='\0' && pass1[i]=='\0')
{
count+=n2-j;
}
printf("count:%d\n",count);
return 0;
}