segmentation fault, recursive palindrome

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2007
Posts: 1,679
Reputation: vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold 
Solved Threads: 193
vmanes's Avatar
vmanes vmanes is offline Offline
Posting Virtuoso

Re: segmentation fault, recursive palindrome

 
0
  #11
Oct 31st, 2008
Originally Posted by DragonReborn225 View Post
thanks for the added help man. Just one question though, whats the point of post-incrementing if pre-incrementing is instantaneous? also did you see any tell tale signs that led to my segmentation faults?? thanks again, and no matter if you didn't see any, you've wasted enough time on this already lol.

edit: working perfectly!!! thanks everyone.
Pre- versus post-incrementing - most of the time it's a matter of style, what the coder prefers. When used in a standalone manner ( nothing else occurring in the statement), it doesn't matter.
  1. x++ ;
  2. //or
  3. ++x;
will give exactly the same results. On the other hand, there's a difference in
  1. p = x++;
  2. //or
  3. p = ++x;
The question is, what do you really mean to occur? This is an easy way to get OBO errors (Off By One) if you don't use the version that correctly implements your algorithm. In code like this, I advise students to separate the increment/decrement from the other actions, that way it's perfectly clear when you want the change to occur.

As I mentioned earlier, to be absolutely clear what you're doing in your function call, just use index-1 as the argument, as you're not really seeking to change the value of index, just passing a value that is one less.

I didn't get any seg fault or other runtime error with your original code, just incorrect result.

Time is never wasted when it's spent helping someone learn something.
(hmm, might make that my new sig)
Everyone's gotta believe in something. I believe I'll have another drink.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 1383 | Replies: 10
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC