[net.lang.c] pointer <==> *pointer ??

bill@uoregon.UUCP (bill) (10/06/84)

[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

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (10/07/84)

Would people please run their examples of "funny quirks in C"
past "lint" before posting them.  Naturally bogus source code
produces funny results.  Remember that many UNIX system C compilers
will quietly accept incorrect usage of the language and generate
code that appears to work.  This is not a defect of C but rather of
the compiler implementation.

greenber@acf4.UUCP (10/09/84)

<>

Remember:

It's not a bug --- it's a feature...


Ross M. Greenberg  @ NYU   ---->  allegra!cmcl2!acf4!greenber  <----