Saturday, 15 September 2012

What is the issue with this reverse array code in c++? -


itemprop = "text">

The program is okay, but when running, it is crashing and it shows: End process with status-1073741819 < / P>

  zero reverse (four * str) {char * end1 = str; Four tmp = 'c'; If (str) {while (* end1) {++ end1; } --end1; While (str & lt; end1) {tmp = * str; * Str = * END1; * END1 = tmp; Str ++; End1--; }}}  

Any ideas? There is absolutely nothing wrong in implementing reverse : Your code will work

Unless the string you pass it is worthless and writable.

Then the way you apply it, there must be something wrong with it. The most common likelihood is to pass the string, which is an undefined behavior that could be the cause of the crash:

  char * s = "quick brown fox"; Reverse (s); // & lt; & Lt; == This would be an undefined behavior  

.


No comments:

Post a Comment