Skip to main content
added 23 characters in body
Source Link
user272752
user272752

labelcnt vs rowcount?? Try harder to be consistent (ie. cnt vs count.) I've suggested camelCase with nRows. I find this preferable but that is no more than my opinion. You're free to formulate your own, but try to apply consistent usages.

labelcnt vs rowcount?? Try harder to be consistent. I've suggested camelCase with nRows. I find this preferable but that is no more than my opinion. You're free to formulate your own, but try to apply consistent usages.

labelcnt vs rowcount?? Try harder to be consistent (ie. cnt vs count.) I've suggested camelCase with nRows. I find this preferable but that is no more than my opinion. You're free to formulate your own, but try to apply consistent usages.

added 113 characters in body
Source Link
user272752
user272752

New-ish coders have a tendency to add extra variables in order to solve a problem. Because these are often scratchpad variables, their names are often related to the primary variable of interest with little to distinguish their 'supporting role' purpose. The virgin reader is left wondering why has something (max) disappeared from view in the code; or has it?

  • One line comment saves reader from wondering "What have we here?"
  • One less variable at 'function scope'
  • size_t used appropriately
  • 0th element initially is the maximum so far
  • 'Greater than' triggers replacement (makes sense to me)
  • Whitespace to aid clarity (style choices)
  • No braces for single line bodies (style choices)
  • No 'magic number' being -1
  • No concern about matching the datatype of the values being compared
  • 'Greater than' triggers replacement (makes sense to me)
  • Whitespace to aid clarity (style choices)
  • No braces for single line bodies (style choices)

New-ish coders have a tendency to add extra variables in order to solve a problem. Because these are often scratchpad variables, their names are often related to the primary variable of interest with little to distinguish their 'supporting role' purpose. The virgin reader is left wondering why has something disappeared from view in the code; or has it?

  • One line comment saves reader from wondering "What have we here?"
  • One less variable at 'function scope'
  • size_t used appropriately
  • 0th element initially is the maximum so far
  • 'Greater than' triggers replacement (makes sense to me)
  • Whitespace to aid clarity (style choices)
  • No braces for single line bodies (style choices)

New-ish coders have a tendency to add extra variables in order to solve a problem. Because these are often scratchpad variables, their names are often related to the primary variable of interest with little to distinguish their 'supporting role' purpose. The virgin reader is left wondering why has something (max) disappeared from view in the code; or has it?

  • One line comment saves reader from wondering "What have we here?"
  • One less variable at 'function scope'
  • size_t used appropriately
  • 0th element initially is the maximum so far
  • No 'magic number' being -1
  • No concern about matching the datatype of the values being compared
  • 'Greater than' triggers replacement (makes sense to me)
  • Whitespace to aid clarity (style choices)
  • No braces for single line bodies (style choices)
added 12 characters in body
Source Link
user272752
user272752
    size_t *labels*labelTallies = calloc( MAX_LABEL_COUNT, sizeof *labels*labelTallies );
    size_t *labels = calloc( MAX_LABEL_COUNT, sizeof *labels );
    size_t *labelTallies = calloc( MAX_LABEL_COUNT, sizeof *labelTallies );
Add warning about calculated floating point values...
Source Link
user272752
user272752
Loading
Add "Shadowing makes for shady code" block
Source Link
user272752
user272752
Loading
added 69 characters in body
Source Link
user272752
user272752
Loading
Touch ups, and a stronger warning against casual use of scanf().
Source Link
user272752
user272752
Loading
added 344 characters in body
Source Link
user272752
user272752
Loading
Add "A bit of fun" block
Source Link
user272752
user272752
Loading
Add "Unnecessary II" block about doubled-up parentheses.
Source Link
user272752
user272752
Loading
Add "Unnecessary" block about explicit return; from the end of a void function.
Source Link
user272752
user272752
Loading
Add "Unnecessary" block about explicit return; from the end of a void function.
Source Link
user272752
user272752
Loading
added 248 characters in body
Source Link
user272752
user272752
Loading
added 482 characters in body
Source Link
user272752
user272752
Loading
Source Link
user272752
user272752
Loading