Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started