#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int main(void) {
char buffer[100];
long num;
bool error = false;
do {
if(error
) printf("The number must be in the range 1 to 5.\n"); fgets(buffer
, sizeof(buffer
), stdin
); //scanf("%100s", buffer);
num
= strtol(buffer
, NULL
, 10); error = true;
} while(num < 1 || num > 5);
printf("chosen number: %ld", num
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRib29sLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKHZvaWQpIHsKCWNoYXIgYnVmZmVyWzEwMF07Cglsb25nIG51bTsKCWJvb2wgZXJyb3IgPSBmYWxzZTsKCQoJZG8gewoJCWlmKGVycm9yKSBwcmludGYoIlRoZSBudW1iZXIgbXVzdCBiZSBpbiB0aGUgcmFuZ2UgMSB0byA1LlxuIik7CgkJZmdldHMoYnVmZmVyLCBzaXplb2YoYnVmZmVyKSwgc3RkaW4pOwoJCS8vc2NhbmYoIiUxMDBzIiwgYnVmZmVyKTsKCQludW0gPSBzdHJ0b2woYnVmZmVyLCBOVUxMLCAxMCk7CgkJZXJyb3IgPSB0cnVlOwoJfSB3aGlsZShudW0gPCAxIHx8IG51bSA+IDUpOwoJCglwcmludGYoImNob3NlbiBudW1iZXI6ICVsZCIsIG51bSk7CgkKCXJldHVybiAwOwp9Cg==