C qsort and pointers

qsort is a C standard library function that can sort arrays of any type in ascending order. It works by using a comparison function, specified by the user, to determine the relative order of elements in the array. This comparison function must take two const void* arguments and return an integer less than, equal to, or greater than zero, depending on whether the first argument is considered less than, equal to, or greater than the second argument, respectively.
Read more →

C const char * vs char *

The difference between const char *str and char *str is the level of protection provided for the string stored at the memory location str points to. const char *str is a pointer to a constant character. This means that the string stored at the memory location str points to cannot be modified through str. Attempting to modify the string will result in a compile-time error. char *str is a pointer to a character that is not constant.
Read more →

C strings

In C, an array of strings is typically stored in memory as a sequence of pointers to the individual strings. The individual strings themselves are stored in contiguous blocks of memory with the final character being a null terminator ('\0'), and each pointer in the array points to the start of one of these blocks. For example: char *strings[] = {"hello", "world", "!"}; Let’s assume that the array of pointers strings is stored at 0x100 and that each string is stored in memory at the following locations:
Read more →