Compile Error -> Integer to Char

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Compile Error -> Integer to Char

Post 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!
_.
CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Re: Compile Error -> Integer to Char

Post 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
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Thanks.

Post 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!
_.
Post Reply

Return to “C++”