Created
July 4, 2024 04:34
-
-
Save jmcph4/3cc5900ebddd56a3961b8e9172dc3b74 to your computer and use it in GitHub Desktop.
Guess a 4-digit PIN
This file contains 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 <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#define MAX_PIN 9999 | |
int main(int argc, char** argv) { | |
if (argc != 2) { | |
printf("usage: guess pin\n"); | |
return EXIT_FAILURE; | |
} | |
uint16_t pin = atoi(argv[1]); | |
for (uint16_t i=0;i<MAX_PIN;i++) { | |
if (i == pin) { | |
printf("done\n"); | |
break; | |
} | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment