Essential C (2003) [pdf]
cslibrary.stanford.edu
Essential C (2003) [pdf]
1–10 of 84 posts
Re: Essential C (2003) [pdf]
#2Re: Essential C (2003) [pdf]
#3Re: Essential C (2003) [pdf]
#4This, paired with their Pointers and Memory [1] guide are how I learned C in college. They're both pretty short and to the point, I would highly recommend. [1] http://cslibrary.stanford.edu/102/PointersAndMemory.pdf
Re: Essential C (2003) [pdf]
#5Ugh. He's talking about inline use of post-increment and pre-increment (i.e. x++ and ++x) here. This is perfectly readable to a C programmer, and sidestepping them actually makes the code harder to understand.
Re: Essential C (2003) [pdf]
#6> Relying on the difference between the pre and post variations of these operators is a classic area of C programmer ego showmanship. Ugh. He's talking about inline use of post-increment and pre-increment (i.e. x++ and ++x) here. This is perfectly readable to a C programmer, and sidestepping them actually makes the code harder to understand.
Re: Essential C (2003) [pdf]
#7> Relying on the difference between the pre and post variations of these operators is a classic area of C programmer ego showmanship. Ugh. He's talking about inline use of post-increment and pre-increment (i.e. x++ and ++x) here. This is perfectly readable to a C programmer, and sidestepping them actually makes the code harder to understand.
Can you give an example where not using them 'inline' makes code harder to understand?
return x++;
:)Re: Essential C (2003) [pdf]
#8> Relying on the difference between the pre and post variations of these operators is a classic area of C programmer ego showmanship. Ugh. He's talking about inline use of post-increment and pre-increment (i.e. x++ and ++x) here. This is perfectly readable to a C programmer, and sidestepping them actually makes the code harder to understand.
Can you give an example where not using them 'inline' makes code harder to understand?
for(i=n; i-- > 0 ;)
{ /* operate on a[i] */ }
converting i--; to a statement at the start of block makes it less clear that it's part of the iteration idiom rather than a ad hoc adjustment that's specific to this particular logic. There are other examples, but they're either more involved or statementification is less obviously wrong.Re: Essential C (2003) [pdf]
#9Re: Essential C (2003) [pdf]
#10Earlier quoted context omitted.
Can you give an example where not using them 'inline' makes code harder to understand?
Consider the idiomatic way of interating backward through a array: for(i=n; i-- > 0 ;) { /* operate on a[i] */ } converting i--; to a statement at the start of block makes it less clear that it's part of the iteration idiom rather than a ad hoc adjustment that's specific to this particular logic. There are other examples, but they're either more involved or statementification is less obviously wrong.
for(i = n-1; i >= 0; i--)
{ /* operate on a[i] */ }
breaks if i is unsigned, like a size_t.