Next Previous Contents

14. Use the array operator [] even for pointers

When addressing an array via a pointer, don't use the plus and dereference operators, but the array operator. This will generate better code in some common cases.

Don't use

        char* a;
        char b, c;
        char b = *(a + c);

Use

        char* a;
        char b, c;
        char b = a[c];

instead.


Next Previous Contents