Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Briggs Elsperger
    @I3uckwheat
    You might have a newer version then
    ryanford-frontend
    @ryanford-frontend
    what version do you have?
    Briggs Elsperger
    @I3uckwheat
    ISBN: 978-1-449-39991-7
    ryanford-frontend
    @ryanford-frontend
    same
    Briggs Elsperger
    @I3uckwheat
    cool :)
    You going to go through it?
    ryanford-frontend
    @ryanford-frontend
    image.png
    i started it, not very far
    Briggs Elsperger
    @I3uckwheat
    I'll jump into it tomorrow
    the lisp one was more language theory instead of C theory. I don't plan to write a langauge anytime soon
    ryanford-frontend
    @ryanford-frontend
    are you using an ide or just your normal editor?
    like codeblocks?
    Briggs Elsperger
    @I3uckwheat
    vim right now
    ryanford-frontend
    @ryanford-frontend
    it would be nice if I could just full throttle into it, but i have a bit on my plate atm
    Briggs Elsperger
    @I3uckwheat
    image.png
    This part is going to be suuuuper interesting
    :drool:
    anyway, off to bed. long day again tomorrow for me
    ryanford-frontend
    @ryanford-frontend
    you might appreciate this then https://beej.us/guide/bgnet/
    Briggs Elsperger
    @I3uckwheat
    @ryanford-frontend ++ saved it :)
    oh...
    oh wow, even asteroids in C
    But yeah.. bedtime for me. Night!
    ryanford-frontend
    @ryanford-frontend
    :wave:
    Briggs Elsperger
    @I3uckwheat
    Strings in C are a real mindfuck
    This C thing is a LOT deeper than I thought lol
    ryanford-frontend
    @ryanford-frontend
    how do you mean?
    Briggs Elsperger
    @I3uckwheat
    There's just a ton to take in about how the compiler does things
      1 #include <stdio.h>
      2 
      3 int main()
      4 {
      5   char *cards = "JQK";
      6   char a_card = cards[2];
      7   cards[2] = cards[1];
      8   cards[1] = cards[0];
      9   cards[0] = cards[2];
     10   cards[2] = cards[1];
     11   cards[1] = a_card;
     12   puts(cards);
     13   return 0;
     14 }
    This doesn't work
    but this does:
      1 #include <stdio.h>
      2 
      3 int main()
      4 {
      5   char cards[] = "JQK";
      6   char a_card = cards[2];
      7   cards[2] = cards[1];
      8   cards[1] = cards[0];
      9   cards[0] = cards[2];
     10   cards[2] = cards[1];
     11   cards[1] = a_card;
     12   puts(cards);
     13   return 0;
     14 }
    I get that it's a pointer to a string literal in the first example, and string literals are not mutateable
    but holy hell... it's difficult for me to wrap my head around how arrays work
    ryanford-frontend
    @ryanford-frontend
    well at a glance all of that is gibberish so.. lol
    Briggs Elsperger
    @I3uckwheat
    basically it's just re-arranging the letters in a string
    ryanford-frontend
    @ryanford-frontend
    glad we'll have you to answer questions when the rest of us jump in :stuck_out_tongue:
    Briggs Elsperger
    @I3uckwheat
    it's an example of not being able to mutate a string literal. char *cards is a pointer to the string literal which is immutable.
    but char cards[] is mutable because it's an array in the memory stack instead of the constants
    (says me parroting the book)
    ryanford-frontend
    @ryanford-frontend
    that makes sense to me
    which book? headfirst c?
    Briggs Elsperger
    @I3uckwheat
    Yeah, that's the one. It's muuuuch better than the BYO Lisp
    ryanford-frontend
    @ryanford-frontend
    are you going to be using C at your work?
    Briggs Elsperger
    @I3uckwheat
    Not sure yet, but it could be useful. I don't need to use it for sure, but if I can apply it there, I become more valuable
    and I can get some real-world C experience for the resume
    ryanford-frontend
    @ryanford-frontend
    :fire:
    Briggs Elsperger
    @I3uckwheat
    C will take me further around here if I can get good at it too
    Briggs Elsperger
    @I3uckwheat
    Oh intersting, there's a bug in the head first C book
    Briggs Elsperger
    @I3uckwheat
    just remember "fgets()" can record newlines