Page 1 of 1

Compile Error -> Integer to Char

Posted: Wed Sep 01, 2004 1:30 am
by _.B._
Greetings!
Need some help here :o
How can I convert an Integer into a Char?
I am getting a "Compile Error" in one program.
The message includes:
In function `char Minesweep()':
implicit declaration of function `int itoa(...)'
In my code I have:
[cpp]#include <iostream.h>
#include <stdlib.h>

...

char Minesweep()
{ unsigned short Mines = 0;
char AuxC[1];

if (Matriz[i-1][j] == '*')
Mines++;
if (Matriz[i-1][j+1] == '*')
Mines++;
if (Matriz[j+1] == '*')
Mines++;
if (Matriz[i+1][j+1] == '*')
Mines++;
if (Matriz[i+1][j] == '*')
Mines++;
if (Matriz[i+1][j-1] == '*')
Mines++;
if (Matriz[j-1] == '*')
Mines++;
if (Matriz[i-1][j-1] == '*')
Mines++;
itoa(Mines,AuxC,10);
return AuxC[0];
}

...
[/cpp]

It runs just fine in Dev-C++ 4.
What can I do?
Thanks in advance!

Re: Compile Error -> Integer to Char

Posted: Wed Sep 01, 2004 9:45 am
by CDiMa
_.B._ wrote:Greetings!
Need some help here :o
How can I convert an Integer into a Char?
I am getting a "Compile Error" in one program.
The message includes:
In function `char Minesweep()':
implicit declaration of function `int itoa(...)'
itoa isn't a standard library function. Write your own itoa and you'll fix this one.

Ciao!!!

Claudio

Thanks.

Posted: Wed Sep 01, 2004 8:28 pm
by _.B._
Greetings!
Thanks for the suggestion CDiMa!
I'll work on that some other time.
Right now, a friend recommended me just to do this:
[cpp]return Mines+'0';[/cpp]
That worked just fine :)
ACed now :)

Keep posting!