Finally I have a valid reason to learn about memory management. It was also hella weird when encountering it.

  • LedgeDrop@lemmy.zip
    link
    fedilink
    arrow-up
    17
    ·
    3 days ago

    Without getting too critical of your code (congrats BTW), never use strcpy instead use strlcpy.

    strcpy will happily allow you to create buffer overflows (a common challenge with C) which will cause your application to crash.

    You’ll find more details here.

    Good luck!

    • da_cow (she/her)@feddit.orgOP
      link
      fedilink
      arrow-up
      9
      ·
      3 days ago

      Thanks, I did not knew this. I always appreciate constructive criticism. I am quite new to C so theres a shit ton of stuff I have never done or dont even know about.

    • ozymandias117@lemmy.world
      link
      fedilink
      English
      arrow-up
      6
      ·
      3 days ago

      And understand when you can use them…

      I’ve seen too much code following this advice blindly that just does something like

      strncpy(dst, src, strlen(src))