I want to check whether the user writes less than 30 characters or not. This is my code below but it can't check user's input by the way I would like. For example if I type 40 characters as input it won't print `Not valid input`. Could anyone explain me how to check that input will be right?

```
int main(int argc, char **argv) {
    char string[31];
    printf("Enter a string: ");
    if (fgets(string, 30, stdin)) {
        printf("Enter a character too: ");
        char c;
        scanf("%c", &c);

        char *ptr = string;

        if (ptr = contains(ptr, c)) {
            printf("Found at position %ld\n", ptr - string + 1);
        } else {
            printf("Character did not found.\n");
        }
    } else {
        printf("Not valid input\n");
    }
    return 0;
}

```