0

Write a program to check whether given username and password entered by user is correct or not.

Write a C program to check whether given username and password entered by user is correct or not, user can check username and password only three times after that program should be terminated. Username: Admin Password: Admin What will be the code for this question? https://code.sololearn.com/cf2cgVZGY78Z/?ref=app

13th Jul 2021, 7:59 AM
Bhakti
Bhakti - avatar
5 odpowiedzi
+ 9
Bhakti , the code for this task should come from you. before we can help you, please do a try by yourself first, put it in playground and link it here. it does not matter if if looks perfect or has some issues, but we can see where you get stuck and give you some useful help. since you have just started learning c with the tutorial, you should be patient as starting to learn a programming language takes some time and effort from you. break the requested task in smaller parts and try to solve them step by step. happy coding and good success!
13th Jul 2021, 8:59 AM
Lothar
Lothar - avatar
+ 2
inxanedev! Yeah it will not work becz in c we cannot compare string directly we need to use strcmp for comparing i gave an idea means flow will look like this which i have mentioned
13th Jul 2021, 5:50 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
Thanks for your advice... I will try my best👍🏻
13th Jul 2021, 9:48 AM
Bhakti
Bhakti - avatar
+ 1
A.S. does that even work? you can't compare arrays like that, it's not a C++ string. You'd need to use strcmp
13th Jul 2021, 5:03 PM
inxanedev!
inxanedev! - avatar
0
Take two variables and set your user name and password Like this const char user[] ="Admin"; same for password cont char password[]="1111" ; Take inputs usernames and passwords then use if condition like this If( user=="Admin")&&(password=="Admin") Print you are able to login Else Do what you want
13th Jul 2021, 1:55 PM
A S Raghuvanshi
A S Raghuvanshi - avatar