Created
February 28, 2026 09:05
-
-
Save diondokter/c41edb945cccbf76890cde3d282419d8 to your computer and use it in GitHub Desktop.
Fil fail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdbool.h> | |
| #include <string.h> | |
| #include <stdio.h> | |
| /* if you compile this source to ./a.out, | |
| * what is the result of "echo filfail | ./a.out" ? */ | |
| struct { | |
| char name[7]; | |
| bool is_restricted; | |
| } user; | |
| int main(void) { | |
| user.is_restricted = true; | |
| printf("Name: "); | |
| fflush(stdout); | |
| gets(user.name); | |
| if(strcmp(user.name, "admin") == 0) { | |
| user.is_restricted = false; | |
| } | |
| if(user.is_restricted) { | |
| puts("access is denied"); | |
| return 1; | |
| } else { | |
| puts("welcome administrator"); | |
| return 0; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ echo FILFAIL | ./a.out | |
| welcome administrator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment