Indexing array...

D

ditiem

I hope this is the correct group. It came out a doubt about speed
when indexing an array in the following way:

for a given pointer p, p[0] contains an address and p[1] an offset.
I must return the content of the address plus the offset.. Which way
is faster and more portable?

1.- *( ((unsigned int*)*p) + *(p+1) ) ;
2.- ((unsigned int*)*p)[ *(p+1) ] ;
3.- *((unsigned int*)(*p ++ + *p)) ;

thanks!
 
S

santosh

On Wednesday 18 Jul 2007 6:51 pm, in comp.lang.c, (e-mail address removed) <
I hope this is the correct group. It came out a doubt about speed
when indexing an array in the following way:

for a given pointer p, p[0] contains an address and p[1] an offset.
I must return the content of the address plus the offset.. Which
way is faster and more portable?

1.- *( ((unsigned int*)*p) + *(p+1) ) ;
2.- ((unsigned int*)*p)[ *(p+1) ] ;
3.- *((unsigned int*)(*p ++ + *p)) ;

In message:
<[email protected]>

You asked exactly the same question and received three responses.
What was wrong with them?
 
C

Coos Haak

Op Wed, 18 Jul 2007 18:56:41 +0530 schreef santosh:
On Wednesday 18 Jul 2007 6:51 pm, in comp.lang.c, (e-mail address removed) <
I hope this is the correct group. It came out a doubt about speed
when indexing an array in the following way:

for a given pointer p, p[0] contains an address and p[1] an offset.
I must return the content of the address plus the offset.. Which
way is faster and more portable?

1.- *( ((unsigned int*)*p) + *(p+1) ) ;
2.- ((unsigned int*)*p)[ *(p+1) ] ;
3.- *((unsigned int*)(*p ++ + *p)) ;

In message:
<[email protected]>

You asked exactly the same question and received three responses.
What was wrong with them?

Perhaps (in fact ;-) he used google groups. They don't show his two, not
yours or the three answers.
 
D

Default User

santosh said:
On Wednesday 18 Jul 2007 6:51 pm, in comp.lang.c, (e-mail address removed) <
You asked exactly the same question and received three responses.
What was wrong with them?

Google Groups was broken again yesterday, posts were not getting out to
their users.



Brian
 
D

ditiem

Perhaps (in fact ;-) he used google groups. They don't show his two, not
yours or the three answers.

yeah... google groups, you are right. If you have any free usenet
server to be used to
read news I would appreciate it a lot.
 
S

santosh

yeah... google groups, you are right. If you have any free usenet
server to be used to
read news I would appreciate it a lot.

nntp.aioe.org
or
news.aioe.org

also

news.gmane.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top