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

Not open for further replies.


Simon Fraser University
Registered Senior Member
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!
I think you need a statement like:

#include <string.h>

at the top of your file.
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.

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!
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.
Not open for further replies.