Linux Newbie help
 help / color / mirror / Atom feed
* C question
@ 2009-10-08  2:12 Rick Brown
  2009-10-08  2:52 ` Manish Katiyar
  2009-10-08  3:02 ` mayur nande
  0 siblings, 2 replies; 6+ messages in thread
From: Rick Brown @ 2009-10-08  2:12 UTC (permalink / raw)
  To: kernelnewbies, linux-newbie

Hello list,

As far as I recall from K&R, isn't pointer arithmetic on a void
pointer banned? And any effort to do that results in an error -
because the compiler won't know by how much size to increment the
pointer for a statement like "ptr++"? But then how about this:

[rick@linux rick]$ cat t.c
#include <stdio.h>
int main()
{
    void *ptr = 0;
    printf("%d \n", ptr+1);
}
[rick@linux rick]$ gcc t.c
[rick@linux rick]$ ./a.out
1
[rick@linux rick]$

It compiles and runs fine ... !

TIA,

Rick

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-10-08  8:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-08  2:12 C question Rick Brown
2009-10-08  2:52 ` Manish Katiyar
2009-10-08  5:37   ` Kalpesh Rathod
2009-10-08  8:48   ` Michał Nazarewicz
2009-10-08  3:02 ` mayur nande
2009-10-08  5:43   ` sandeep lahane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox