What would be considered better code? (in C)

Discussion in 'Computer Programming, Emulation, and Game Modding' started by Monado_III, Aug 15, 2015.

  1. Monado_III
    OP

    Monado_III GBAtemp Advanced Fan

    Member
    638
    353
    Feb 8, 2015
    Canada
    /dev/null
    Out of these two examples, what would be considered better code, in terms of readability and what is generally considered good practice (and why)? They do the same thing minus one or two formatting things that I'm sure I could work out with enough google searches. (I made isgraph1.txt and isgraph.txt was taken from a book and intentionally cut the comments out)
     

    Attached Files:

    Last edited by Monado_III, Aug 16, 2015
  2. Monado_III
    OP

    Monado_III GBAtemp Advanced Fan

    Member
    638
    353
    Feb 8, 2015
    Canada
    /dev/null
  3. JaapDaniels

    JaapDaniels GBAtemp Fan

    Member
    361
    66
    Apr 22, 2012
    Netherlands
    quick look says
    isgraph.txt
    but then again i'm not a coder
    it reads much better
     
  4. palasx

    palasx Advanced Member

    Newcomer
    97
    0
    Oct 17, 2007
    United States
    The case switch is usually faster, as you only end up putting the variable to be compared in the stack once, instead of once for each IF comparison.