pointer <==> *pointer ??

bill bill at uoregon.UUCP
Sat Oct 6 09:31:00 AEST 1984


[this line intentionally left blank]

For those who are amused by C quirks:

While attempting to fix a program bug, I changed the code from 
arragement A to arrangement B (below).

--- A ---

char strings[SIZE1][SIZE2];

teststr(str)
char *str;
{
	register char (*b)[SIZE2] = strings;

	while (b < &strings[SIZE1]) {
		if (strcmp(str, b) == 0)
			break;
		b++;
	.
	.
	.
}

--- B ---

char strings[SIZE1][SIZE2];

teststr(str)
char *str;
{
	register char (*b)[SIZE2] = strings;

	while (b < &strings[SIZE1]) {
		if (strcmp(str, *b) == 0)
			break;
		b++;
	.
	.
	.
}

The result, of course, is that nothing changes.

	Randy Goodall, Perfect Software, Inc. (curtesy bill)

	{tektronix,hpcvra,hp-pcd}!uoregon!bill



More information about the Comp.lang.c mailing list