From: Rick Brown <rick.brown.3@gmail.com>
To: kernelnewbies <kernelnewbies@nl.linux.org>, linux-newbie@vger.kernel.org
Subject: C question
Date: Thu, 8 Oct 2009 07:42:18 +0530 [thread overview]
Message-ID: <7783925d0910071912u5e4f4a2au8442cb6537cd35ed@mail.gmail.com> (raw)
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
next reply other threads:[~2009-10-08 2:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-08 2:12 Rick Brown [this message]
2009-10-08 2:52 ` C question 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7783925d0910071912u5e4f4a2au8442cb6537cd35ed@mail.gmail.com \
--to=rick.brown.3@gmail.com \
--cc=kernelnewbies@nl.linux.org \
--cc=linux-newbie@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox