Question: Is there a Python Client-Side API for Discord?
I don't need much, just to listen to events like getting a call or a message.

Is it possible?

Answer: 
The `char record[121]` variable is actually an *array* of characters, otherwise known as a *string*. It is used here so that, if an erroneous input is given (instead of a valid *integer* input), then the input stream is still cleared by the `fgets()` call, which takes in *all* characters up to (and including) the newline character.

The `sscanf` function then attempts to extract a valid integer from the read character string and, if it fails, then an error value (`-1`) is assigned to signal that fact. If it succeeds, it assigns the given input value to `number`, in the same way that a *successful* call to `scanf("%d", &number)` would.

However, just using such a simple `scanf()` call would potentially leave 'unprocessed' characters in the input stream, which could cause problems for any subsequent input operations (or require the input stream to be cleared).

---

Using such a technique will also prevent undesired/unexpected effects caused by a user typing *extra* characters after a valid input. For example, the following (deliberately bad) code will cause a 'surprise' if you enter `1a` in response to the first prompt:

```c
#include <stdio.h>

int main()
{
    int number = 0, number2 = 0;
    printf("Enter first number: ");
    scanf("%d", &number);
    printf("Enter second number: ");
    scanf("%d", &number2);
    printf("Given numbers were: %d and %d.\n", number, number2);
    return 0;
}

```

However, using the `getNum()` function your teacher provided, the following code is much more robust:

```c
int main()
{
    int number = 0, number2 = 0;
    printf("Enter first number: ");
    number = getNum();
    printf("Enter second number: ");
    number2 = getNum();
    printf("Given numbers were: %d and %d.\n", number, number2);
    return 0;
}

```
The function is reading input as text, storing it to the character *array* `record`. It then converts that string into an equivalent integer value using `sscanf`.

This is a bit safer than just using `scanf` directly - it ensures that if the user types non-numeric input, it's still consumed from the input stream so that it doesn't cause problems later on.