prev up next   top/contents search

comp.lang.c FAQ list · Question 20.23

Q: Does C have an equivalent to Pascal's with statement?

A: No. The way in C to get quick and easy access to the fields of a structure is to declare a little local structure pointer variable (which, it must be admitted, is not quite as notationally convenient as a with statement and doesn't save quite as many keystrokes, though it is probably safer). That is, if you have something unwieldy like

	structarray[complex_expression].a =
		structarray[complex_expression].b +
you can replace it with
	struct whatever *p = &structarray[complex_expression];
	p->a = p->b + p->c;

prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North