Question: C PROGRAMMING Exercise two Here is a demonstration C program auth.c: #include #include int main() { extern int authenticate(); if (authenticate() == 2) { printf(Login
C PROGRAMMING Exercise two
Here is a demonstration C program auth.c:
#include#include int main() { extern int authenticate(); if (authenticate() == 2) { printf("Login incorrect. "); return(1); } printf("Access to secret stuff achieved "); return(0); } int authenticate() { char buf[80]; printf("Password: "); if (fgets(buf, sizeof buf, stdin) == NULL) return(0); else if (strcmp(buf, "sesame ") == 0) return(1); else return(2); }
1. Compile and run this. The password is "sesame". Try running it with and without the correct password.
2. Suppose you did not know that the password was sesame but you could see the rest of the source code. Run the program and get it to print "Access to secret stuff achieved" without typing "sesame".
3. Fix the bug.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
