diff --git a/misc/lexicographic_permutations.c b/misc/lexicographic_permutations.c index cccb9fbb..10f8cedf 100644 --- a/misc/lexicographic_permutations.c +++ b/misc/lexicographic_permutations.c @@ -50,9 +50,13 @@ void PrintSortedPermutations(char *str) int main() { - unsigned int n; // size of string - scanf("%u\n", &n); - + int n; // size of string + scanf("%d\n", &n); + if (n <= 0 || n >= 1000) + { + perror("Input number out of range: >0 and <1000\n"); + return -1; + } char *str = (char *)malloc(n * sizeof(char)); scanf("%s", str); PrintSortedPermutations(str);