int x; x = 10; *(x + 4) = 10;
Array indexing has a cleaner syntax but (as I've read) pointer arithmetic is faster. My question is, is it worth to use pointer arithmetic? Is there a noticeable difference?
[QUOTE]Array indexing has a cleaner syntax[/QUOTE] You said it yourself! So why bother and make your life difficult. When you come back later to your code it will be more easy to understand then if you used pointer arithmetic. If you have a good C++ compiler he would translate both … Read More
>but (as I've read) pointer arithmetic is faster Prove it. In your example, the two are quite likely compiled to exactly the same machine code. Array subscripting is literally syntactic sugar for the equivalent pointer offset calculation. A more likely example is this: [code=cplusplus] int x[N]; int *p = x; … Read More