What would be considered better code? (in C)

Monado_III

Well-Known Member
OP
Member
Joined
Feb 8, 2015
Messages
722
Trophies
0
Location
/dev/null
XP
1,443
Country
Canada
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)
 

Attachments

  • isgraph1.txt
    674 bytes · Views: 370
  • isgraph.txt
    851 bytes · Views: 439
Last edited by Monado_III,

palasx

Well-Known Member
Newcomer
Joined
Oct 17, 2007
Messages
98
Trophies
1
XP
227
Country
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.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: Sbeve