Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

password protection code

$
0
0

in output,it is telling invalid password even though i hav entered right password(helloINDIA).

#include <stdio.h>
#include<string.h>
#include<conio.h>
void main()
{ 
char s1[20]="helloINDIA",s2[20],ch;
int i=0;
printf("enter password :\n");
while(ch!=13)    //ascii of enter key is 13
{
  ch=getch();
  s2[i]=ch;
  printf("*");
  i++;
}
s2[i]='\0';
if(strcmp(s1,s2)==0)
  printf(" password is valid");
else
  printf(" invalid password");

}

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>