View Full Version : Help please: itoa() - implicit declaration of function...


Weitzel
02-02-02, 06:18 PM
Hi... I know there are better boards for this but I was hoping someone out there would immediately recognize the fix for this. I'm a student and the assignment is due Wednesday so the sooner the better =)

In C++, I have:

int score;
char str[50];

itoa(score, str, 10);

I'm trying to convert my integer "score" into a string - I figured itoa was the best way. It worked fine in Visual C++ but now that I'm compiling at school on a Unix machine, it gives me the error:

implicit declaration of function 'int atoi(...)'

How do I use atoi "explicitly"??? Thanks!

James R
02-03-02, 06:36 PM
I think you need a statement like:

#include <string.h>

at the top of your file.

malisha
02-03-02, 07:52 PM
hi there Weitzel ,

itoa is not a standard function, its found in stdlib.h
so #include<stdlib.h> if itoa still does not work that means that the function is not present in the partiucalr distro of c++ u have, the best other way to do it would be to uses sprintf look at the function prototype on google or sumthing and it should show you how to do it.

hope that helps.

Weitzel
02-04-02, 12:43 AM
Malisha,

I completely agree with your guess that itoa must not be present in the version of stdlib.h at school. I ended up using sprintf instead and it works. Thanks!

malisha
02-04-02, 03:48 AM
hey its cool, no problems.
If you want some really good help though for other questions you might have go to this website, the people here really know whats happening and they answer quick most of the time as well.

http://www.linuxnewbie.org