Messages in this thread | | | Date | Mon, 23 Feb 2004 14:49:11 -0800 | From | Mitchell Blank Jr <> | Subject | Re: &array considered harmful? |
| |
Robert T. Johnson wrote: > memset(&A, 0, sizeof(A)); [...] > This works because in C, for a local array, &A == A. The problem is > that this is very brittle.
I'm probably in the minority here, but I've gotten into the habit of saying "&A[0]" since I think it's more explicit ("I want the address of the FIRST ELEMENT of the array") and it avoids exactly the problems you mention. It's true that it's equivelent to just saying "A" (well, almost - if "A" is a pointer then it could be an lvalue while "&A[0]" never is) but I like the visual cue of that "&" provides. Matter of taste I guess - I'm sure some people consider it ugly.
-Mitch - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |