Use strtol in guess.c; UTF-8 in cat.py !2
2 files changed, +2 −2
Layout: unified · split
c/guess.c +1 −1
| @@ -24,7 +24,7 @@ int main() { | |||
| 24 | if(fgets(line, sizeof line, stdin) != NULL) | 24 | if(fgets(line, sizeof line, stdin) != NULL) |
| 25 | { | 25 | { |
| 26 | // Convert user input to an integer | 26 | // Convert user input to an integer |
| 27 | int user_input = atoi(line); | 27 | int user_input = (int)strtol(line, NULL, 10); |
| 28 | 28 | ||
| 29 | // Do the main comparison to determine if the guess is correct | 29 | // Do the main comparison to determine if the guess is correct |
| 30 | if (user_input == random_number) { | 30 | if (user_input == random_number) { |
python/cat.py +1 −1
| @@ -7,7 +7,7 @@ args = parser.parse_args() | |||
| 7 | 7 | ||
| 8 | # Open the file using the `file` argument | 8 | # Open the file using the `file` argument |
| 9 | path = args.file | 9 | path = args.file |
| 10 | with open(path, 'r') as file: | 10 | with open(path, 'r', encoding='utf-8') as file: |
| 11 | # Read and print the file contents | 11 | # Read and print the file contents |
| 12 | contents = file.read() | 12 | contents = file.read() |
| 13 | print(contents) | 13 | print(contents) |