Created
November 13, 2019 23:13
-
-
Save taeber/97985286a1739f56bedbd977ca8e5566 to your computer and use it in GitHub Desktop.
Fake say program
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
// Fake say program | |
// | |
// Author: | |
// Taeber Rapczak <[email protected]> | |
// | |
// Compile: | |
// $ cc -o say fakesay.c | |
// Example: | |
// $ ./say hi | |
// $ ./say alexa unlock front door | |
// Alert! Front door unlocked. | |
#include <stdio.h> | |
#include <string.h> | |
int main(int argc, char *argv[]) { | |
const char *expected[] = {"", "alexa", "unlock", "front", "door"}; | |
const char *together = "alexa unlock front door"; | |
if (argc == 2 && strcmp(together, argv[1]) == 0) | |
goto SUCCESS; | |
if (argc != sizeof(expected)/sizeof(expected[0])) | |
return 1; | |
for (int i = 1; i < sizeof(expected)/sizeof(expected[0]); i++) { | |
if (strcmp(argv[i], expected[i]) != 0) | |
return 1; | |
} | |
SUCCESS: | |
puts("Alert! Front door unlocked."); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment