• IHeartBadCode@kbin.social
    link
    fedilink
    arrow-up
    8
    ·
    1 year ago

    char**

    So that you can have an array of strings. It’s useful to remember that in C arrays and pointers are exactly the same thing, just syntax sugar for however you want to look at it. There are a few exceptions where this isn’t true however:

    1. Argument of the & operator
    2. Argument of sizeof
    3. C11 has alignof which decay is a no-no
    4. When it’s a string literal of char[] or wide literal of wchar_t[], so like char str[] = "yo mama";

    But int** is just an array of int*, which likewise int* can just be an array of int. In the picture here, we have int** anya that is an array of int* with a size of 1, int* anya that is an array of int with a size of 1, and then of course our int there being pointed to by int* anya.