Casting pointers

David Silberberg davids at stsci.EDU
Thu Jul 19 22:57:05 AEST 1990


Does anyone know if the following cast operation will perform correctly?

main()
{
	SOME_STRUCT_TYPE	*ptr;
	int			num_chars;

	...
	(char *)ptr += num_chars;
	...
}


If the last line above were replaced by

	 ptr = (char *)ptr + num_chars;

it would perform as desired.  Does casting work on an lvalue?

David Silberberg
(davids at stsci.edu)



More information about the Comp.lang.c mailing list