#### <ctype.h> : Character Type Library

The `<ctype.h>` header is part of the C Standard Library. It provides functions for classifying and converting characters.

### Common functions

| Function     | Description                                 |
| ------------ | ------------------------------------------- |
| `isalpha(c)` | Checks if a character is a letter.          |
| `isdigit(c)` | Checks if a character is a digit (0–9).     |
| `isalnum(c)` | Checks if a character is a letter or digit. |
| `islower(c)` | Checks if a character is lowercase.         |
| `isupper(c)` | Checks if a character is uppercase.         |
| `isspace(c)` | Checks if a character is whitespace.        |
| `toupper(c)` | Converts a lowercase letter to uppercase.   |
| `tolower(c)` | Converts an uppercase letter to lowercase.  |


> [!important] Important: Functions like `toupper()` and `tolower()` return the converted character rather than modifying the original variable directly.

#### <stdlib.h> : Standard Library

The `<stdlib.h>` header is part of the C Standard Library. It provides functions for **memory management, string-to-number conversion, dynamic memory allocation, random number generation, and program control**.

### Common functions

|Function|Description|
|---|---|
|`atoi(s)`|Converts a string to an `int`.|
|`atof(s)`|Converts a string to a `double`.|
|`strtol(s, end, base)`|Converts a string to a `long`.|
|`strtoul(s, end, base)`|Converts a string to an `unsigned long`.|
|`malloc(size)`|Allocates a block of memory dynamically.|
|`calloc(n, size)`|Allocates memory and initializes it to zero.|
|`realloc(ptr, size)`|Resizes a previously allocated memory block.|
|`free(ptr)`|Releases dynamically allocated memory.|
|`rand()`|Generates a pseudo-random integer.|
|`srand(seed)`|Sets the seed for random number generation.|
|`abs(n)`|Returns the absolute value of an integer.|
|`exit(status)`|Terminates the program with a specified status.|
|`qsort(...)`|Sorts elements in an array.|
|`bsearch(...)`|Performs a binary search on a sorted array.|

### Common constants

|Constant|Description|
|---|---|
|`EXIT_SUCCESS`|Indicates successful program termination.|
|`EXIT_FAILURE`|Indicates unsuccessful program termination.|
|`NULL`|Represents a null pointer constant.|

### Example: String-to-number conversion

```
unsigned long val = strtoul(argv[1], NULL, 10);
```

- `argv[1]` → First user-provided command-line argument (string).
    
- `NULL` → Conversion end position is not needed.
    
- `10` → Decimal number system.
    

**Important:**

- `malloc()`, `calloc()`, and `realloc()` allocate memory that must eventually be released using `free()`.
    
- `strtol()` and `strtoul()` provide better error-checking capabilities than `atoi()`.
    
- `EXIT_SUCCESS` and `EXIT_FAILURE` are commonly used as return values from `main()` to indicate whether a program completed successfully.