James Colannino wrote: > Hey everyone. I've heard (and have also read in "The C Programming > Language") that pointer arithmetic in place of arrays is, in general, > faster. However, I've also heard that modern compilers automatically > make optimizations that account for this difference. > > In everyone's opinion, taking both readability and issues of speed into > account, what is better to use? I'd imagine this would depend on the > situation. Just trying to pick up better coding habits as I learn :) In most cases, I'd recommend array indexing. If something can reasonably be expressed in either form, array indexing is usually clearer (both to read and to debug), and compilers which don't optimise array access are rare enough not to be worth worrying about. -- Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx> - : send the line "unsubscribe linux-c-programming" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html