itoa on Dev??

This is a discussion on itoa on Dev?? within the C++ Programming forums, part of the General Programming Boards category; I'm using Dev-C++ 4.9.9.2 and this seems weird to me. I have used itoa on the older version of Dev-C++ ...

  1. #1
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532

    itoa on Dev??

    I'm using Dev-C++ 4.9.9.2 and this seems weird to me. I have used itoa on the older version of Dev-C++ and it worked but now I try to use it on the new one and it says that it's undeclared, yet I looked into stdlib.h and I see it declared. Here is a sample program that won't work on my compiler:
    Code:
    #include <iostream>
    #include <cstdlib>
    
    int main()
    {
        int a=5;
        char buffer[256];
        itoa(a,buffer,10);  //Error right here, undeclared.....
        return 0;
    }
    Anybody know why this is happening?? I mean I used it before on the older Dev and it worked fine. I even looked in stdlib.h and it is in there. Any suggestions?
    Last edited by jmd15; 10-23-2005 at 08:48 AM.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,259
    <cstdlib> should work. Are you sure you installed Dev-C++ correctly?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Yeah I found it, sorry about that. I thought I had the files sorted by filename but whatever. Still the itoa undeclared error though.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Code:
    #include <iostream>
    #include <cstdlib>
    
    using namespace std;
    
    int main()
    {
        int a=523;
        char buffer[256];
        itoa(a,buffer,10);
        cout<<buffer<<endl;
        cin.ignore();
        return 0;
    }
    Works fine on 4.9.9.1

  5. #5
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Yeah, I still got that undeclared error on the code you posted Thantos. I am going to reinstall it.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  6. #6
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    On reinstall it did nothing. Still getting this:
    Code:
    10 C:\Documents and Settings\Admin\Desktop\itoatest.cpp `itoa' undeclared (first use this function)
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Uninstall it, delete all left over files, and then reinstall it. Also make sure your include directory in set correctly

  8. #8
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    it works for me. and i use the same DEV.

  9. #9
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Yeah, pretty sure it's a bad install. On my laptop it works fine, it's the XP Pro one that doesn't. I will delete everything, I was hoping I wouldn't have to because now I have to install a bunch of DevPaks, but oh well. Thanks.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  10. #10
    Registered User
    Join Date
    Aug 2005
    Posts
    13
    try putting in your code :

    using namespace std;

    that's the only difference between your code and that of the person that says theirs works.

  11. #11
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    I didn't put that because I'm not using anything that requires to use that namespace. I'm not using cout, cin, etc, just a program that uses itoa and I figured out that it was the install, I just needed to reinstall it and clear all previous data.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  12. #12
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Doh. If you are using <cstdio> then itoa is in the std namespace.

  13. #13
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,812
    Why not use a portable option like a stringstream or sprintf if you like c-style better.
    Woop?

  14. #14
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    I'm not using cstdio. I do prefer some aspects of C but mainly like C++.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  15. #15
    Me
    Join Date
    Jul 2006
    Posts
    71
    Quote Originally Posted by jmd15
    I'm not using cstdio. I do prefer some aspects of C but mainly like C++.
    You still have to have "using namespace std" as it has the c before it, or you could just use <stdlib.h>, It's the same thing, except when using cstdlib, you have to have "using namespace std;" As that is where those functions are stored.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem using itoa
    By g_p in forum C Programming
    Replies: 2
    Last Post: 05-03-2008, 07:38 AM
  2. Really Weird itoa Problem
    By Grantyt3 in forum C++ Programming
    Replies: 8
    Last Post: 12-20-2005, 12:44 AM
  3. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 01:05 AM
  4. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 08:43 PM
  5. Tutorial about Bloodshed Dev!
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 11-13-2001, 07:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21