You are using a version without Ads of this website. Please, consider donating:

### Run-Time Check Failure #2 - Stack around the variable 'aux' was corrupted.

cant find my error :S
Run-Time Check Failure #2 - Stack around the variable 'aux' was corrupted.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142`` ``````#include using namespace std; bool TestaSeCapicua(int num); int main() { int num, certo; cout << "enter number with 6 digits: "; cin >> num; TestaSeCapicua(num); if (TestaSeCapicua(num)==3) cout << "the number is palindrome" << endl; else cout << "the number its no palindrome" << endl; system("pause"); return 0; } bool TestaSeCapicua(int num) { int aux[6], certo=0; for (int i=0; i<=6; i++) { aux[i] = num % 10; num /= 10; } for (int i=0; i<=3; i++) { for (int j=6; j==3; j--) { if (aux[i]==aux[j]) { certo = certo + 1; return certo; } else { return 0; break; } } } }``````
`for (int i=0; i<=6; i++) // here you are looping 7 times? `
for the division of the number , thats fine, but 'aux' gives me problems
wait...
Last edited on
why? i cant understand. :s
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647`` ``````#include using namespace std; int TestaSeCapicua(int num); int main() { int num; cout << "enter number with 6 digits: "; cin >> num; TestaSeCapicua(num); if (TestaSeCapicua(num)==3) cout << "the number is palindrome" << endl; else cout << "the number its no palindrome" << endl; system("pause"); return 0; } int TestaSeCapicua(int num) { int aux[6] = {0}; int certo=0; for (int n=0; n<=5; ++n) { aux[n] = num % 10; num /= 10; } for (int i=0; i<=3; ++i) { for (int j=6; j!=3; --j) { if (aux[i] == aux[j]) { certo = certo + 1; return certo; } else { return 0; break; } } } return 0; }``````
the code, isnt working, it gives me always the same result.
"the number its no palindrome"
simply your loop should be declared correctly..

 ``123456`` ``````int Iarray[5] = {0}; for (int i=0; i<=5; i++) //this is wrong,,, here you are looping 6 times consider 0 { Iarray[i] = i +1; }``````

hmm limme check it again cuz i thought you wanted aux to be fixed
Last edited on
Topic archived. No new replies allowed.

You are using a version without Ads of this website. Please, consider donating: