Reverse a pointer to a set of integers

Reply

Join Date: Sep 2008
Posts: 273
Reputation: Sci@phy will become famous soon enough Sci@phy will become famous soon enough 
Solved Threads: 42
Sci@phy's Avatar
Sci@phy Sci@phy is offline Offline
Posting Whiz in Training

Re: Reverse a pointer to a set of integers

 
0
  #11
Nov 13th, 2008
You have to do it for EACH i.
So put it in for loop
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 9
Reputation: JpegUser is an unknown quantity at this point 
Solved Threads: 0
JpegUser JpegUser is offline Offline
Newbie Poster

Re: Reverse a pointer to a set of integers

 
0
  #12
Nov 13th, 2008
yes sure that's what i did and got the result 1...50...1. It's weird and i'm sure i have checked my loops a couple of times. Perhaps any other alternatives?
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 273
Reputation: Sci@phy will become famous soon enough Sci@phy will become famous soon enough 
Solved Threads: 42
Sci@phy's Avatar
Sci@phy Sci@phy is offline Offline
Posting Whiz in Training

Re: Reverse a pointer to a set of integers

 
0
  #13
Nov 13th, 2008
Please post entire code, because your code should work then.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 9
Reputation: JpegUser is an unknown quantity at this point 
Solved Threads: 0
JpegUser JpegUser is offline Offline
Newbie Poster

Re: Reverse a pointer to a set of integers

 
0
  #14
Nov 13th, 2008
here:

  1. int temp[ptr_size];
  2. int ptr_size2 = ptr_size;
  3.  
  4. for (i=0;i<ptr_size;i++) {
  5. temp[i] = ptr[ptr_size2--];
  6. }
  7.  
  8. for (i=0;i<ptr_size;i++) {
  9. ptr[i] = temp[i];
  10. }

The second for loop is to get back a reversed ptr.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC