• affiliate@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    13 days ago

    i will never forgive C for making the type syntax be

    char* args[]
    

    instead of the much more reasonable

    &[char] args 
    

    it also bothers me that char* args[] and char c are “the same type” in the sense that the compiler lets you write

    char c, *args[5];
    

    with no problems. i think the C languages would be way easier to learn if they had better type syntax. don’t even get me started on C++ adding support for

    auto fn_name() -> ReturnType { … }
    
      • CarrotsHaveEars@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        12 days ago

        It could, but not necessarily.

        char **args can just mean you have a pointer which points to an address, and at that address, you can get a second address. Follow the second address, there is a char saved there.

        On the other hand, char *args[] means " follow this address to find a list of characters".

        • Oriel Jutty@infosec.exchange
          link
          fedilink
          arrow-up
          0
          ·
          12 days ago

          @racketlauncher831 As far as the C compiler is concerned, there is literally no difference between those two notations. If you declare a function parameter as an array (of T), the C compiler automatically strips the size information (if any) and changes the type to pointer (to T).

          (And if we’re talking humans, then char *args[] does not mean “follow this address to find a list of characters” because that’s the syntax for “array of pointers”, not “pointer to array”.)

  • lily33@lemm.ee
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    14 days ago

    That is why I use just int main(){...} without arguments instead.