Hi,
I'm trying to use itoa() into a MOD5213 project but the compiler doesn't recognize it.
The manual says that itoa() needs system.h and utils.h found in C:\Nburn\include but I only have inlcuded into my project C:\Nburn\include_nn and system.h and utils.h doesn't contain itoa() function.
Is it possible to use itoa() with MOD5213?
Do I have to include C:\Nburn\include and C:\Nburn\include_nn ?
Thanks,
Alejandro
itoa() into MOD5213
-
- Posts: 4
- Joined: Mon Oct 29, 2012 8:44 am
Re: itoa() into MOD5213
This code works:
/* itoa: convert n to characters in s */
void itoa(int n, char s[])
{
int i, sign;
if ((sign = n) < 0) /* record sign */
n = -n; /* make n positive */
i = 0;
do { /* generate digits in reverse order */
s[i++] = n % 10 + '0'; /* get next digit */
} while ((n /= 10) > 0); /* delete it */
if (sign < 0)
s[i++] = '-';
s = '\0';
reverse(s);
}
/* reverse: reverse string s in place */
void reverse(char s[])
{
int i, j;
char c;
for (i = 0, j = strlen(s)-1; i<j; i++, j--) {
c = s;
s = s[j];
s[j] = c;
}
}
/* itoa: convert n to characters in s */
void itoa(int n, char s[])
{
int i, sign;
if ((sign = n) < 0) /* record sign */
n = -n; /* make n positive */
i = 0;
do { /* generate digits in reverse order */
s[i++] = n % 10 + '0'; /* get next digit */
} while ((n /= 10) > 0); /* delete it */
if (sign < 0)
s[i++] = '-';
s = '\0';
reverse(s);
}
/* reverse: reverse string s in place */
void reverse(char s[])
{
int i, j;
char c;
for (i = 0, j = strlen(s)-1; i<j; i++, j--) {
c = s;
s = s[j];
s[j] = c;
}
}
acobadolato wrote:Hi,
I'm trying to use itoa() into a MOD5213 project but the compiler doesn't recognize it.
The manual says that itoa() needs system.h and utils.h found in C:\Nburn\include but I only have inlcuded into my project C:\Nburn\include_nn and system.h and utils.h doesn't contain itoa() function.
Is it possible to use itoa() with MOD5213?
Do I have to include C:\Nburn\include and C:\Nburn\include_nn ?
Thanks,
Alejandro