0

:cry: I have spent hours on this program and cannot get it to produce negatives or INT_MIN. Here is my code. Any help would be so appreciated I can't even begin to tell you...

```
#include <stdio.h>
#include <iostream>
using namespace std;
char *strrev(char *);
char *itoa_3(int, char *, int);
int main()
{
char A[40];
cout << "cout base 10" << endl;
cout << 17 << endl;
cout << 0 << endl;
cout << -17 << endl;
cout << INT_MAX << endl;
cout << INT_MIN << endl;
cout << "\ncout base 16" << endl;
cout << hex << 17 << endl;
cout << 0 << endl;
cout << -17 << endl;
cout << INT_MAX << endl;
cout << INT_MIN << endl;
cout << dec;
cout << "\nitoa_3 base 2" << endl;
cout << itoa_3(17, A, 2) << endl;
cout << itoa_3(0, A, 2) << endl;
cout << itoa_3(-17, A, 2) << endl;
cout << itoa_3(INT_MAX, A, 2) << endl;
cout << itoa_3(INT_MIN, A, 2) << endl;
cout << "\nitoa_3 base 10" << endl;
cout << itoa_3(17, A, 10) << endl;
cout << itoa_3(0, A, 10) << endl;
cout << itoa_3(-17, A, 10) << endl;
cout << itoa_3(INT_MAX, A, 10) << endl;
cout << itoa_3(INT_MIN, A, 10) << endl;
cout << "\nitoa_3 base 16" << endl;
cout << itoa_3(17, A, 16) << endl;
cout << itoa_3(0, A, 16) << endl;
cout << itoa_3(-17, A, 16) << endl;
cout << itoa_3(INT_MAX, A, 16) << endl;
cout << itoa_3(INT_MIN, A, 16) << endl;
cout << "\nitoa_3 base 32" << endl;
cout << itoa_3(17, A, 32) << endl;
cout << itoa_3(0, A, 32) << endl;
cout << itoa_3(-17, A, 32) << endl;
cout << itoa_3(INT_MAX, A, 32) << endl;
cout << itoa_3(INT_MIN, A, 32) << endl;
cout << "\nitoa_3 base 36" << endl;
cout << itoa_3(17, A, 36) << endl;
cout << itoa_3(0, A, 36) << endl;
cout << itoa_3(-17, A, 36) << endl;
cout << itoa_3(INT_MAX, A, 36) << endl;
cout << itoa_3(INT_MIN, A, 36) << endl;
return 0;
}
char *strrev(char *str) {
char *p1, *p2;
if (!str || !*str)
return str;
for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) {
*p1 ^= *p2;
*p2 ^= *p1;
*p1 ^= *p2;
}
return str;
}
char *itoa_3(int n, char *s, int b) {
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
int i=0, sign;
if ((sign = n) < 0)
n = -n;
do {
s[i++] = digits[n % b];
} while ((n /= b) != 0);
if (sign < 0)
s[i++] = '-';
s[i] = '\0';
return strrev(s);
}
```