11
Kirk
6y

Today I started setting up an environment to learn C. It's my first dive into anything more complex than PHP. Wish me luck!

Also, any hints for a beginner in C?

Comments
  • 8
    Pointers are just numbers (You can even add and subtract them)! They represent where your data is in memory.

    Try to avoid malloc but don't be afraid of it. It's just a slow operation.

    The #include uses <> around .h files your SYSTEM has, and "" around .h files your PROJECT has.

    Structs are your best friend.

    String input from the command line is a bitch!

    Strings are a bitch!

    C is a bitch!

    The best bitch.
  • 1
    A good debugger will be your best friend.
  • 1
    @Lasagna I know it's a basic question, but what's the best way to set up a C compiler on Windows? This is all new to me and I'm pretty lost :/
  • 1
    @AlgoRythm As a C-noob: What's the alternative to malloc? I mean a pointer needs memory and how else is it supposed to get it?

    @Kirk If you're a student, I'd recommend downloading Cygwin as a C-compiler anf JetBrains CLion. In my case, CLion pretty much handled and setup everything for me
  • 2
    It is the software equivalent of an elephant gun, check your aim twice and try not to shoot your 'nads off!
  • 1
    @gathurian If you are uncertain if/when you need a lot of memory, use malloc. Otherwise use a stack allocated variable. Also be aware that most os will look your program if you stack allocate a massive buffer
  • 0
    Sorry, I meant kill, not look
  • 0
    @Lasagna yeah, turns out Windows is the hardest one to set up. How about Linux/Ubuntu?
  • 1
    Why not learn go or rust they are also quite fast. Not comparing go to C but go is pretty fast and a nice alternative to C
  • 0
    Use valgrind, it really helps finding those nasty memory leaks that randomly coulse your program to crash somewhere.
Add Comment