Software Error Message

Hi!

can anybody explain following error message:

tmp/1388.cpp:105: implicit declaration of function `int ltoa(...)'

line 105:
ltoa(long, string[100], 10);

thanks,
matt

Comments

  • [b][red]This message was edited by the Null and Void at 2002-5-31 17:5:37[/red][/b][hr]
    It's not an error (in C, at least), it's a warning. However, it will lead to a runtime error if ltoa doesn't exist. The function ltoa is NOT standard, and probably won't exist. Replace that code with this (in C; this is somewhat of a guess of what the parameters in ltoa mean):
    [code]
    snprintf(string, 10, "%ld", long);
    [/code]
    And make sure to include stdio.h. Include cstdio instead if you're using C++ (I see the .cpp extension). You could also use stringstream, but you're already using a character array, so I'll just leave it at that. BTW: You shouldn't be able to use 'long' as a variable name, but you're getting away with it somehow...
  • Well, it depends. Are you declaring the function or calling it?
    If you are calling it, don't put the type names in. "long" is a
    type name, I assume String is too.
    If you are calling the function in your program, don't use variable names like "long" which is a key word.
    If this is a declaration, then you must give the function return type and drop the constant "10".


    : Hi!
    :
    : can anybody explain following error message:
    :
    : tmp/1388.cpp:105: implicit declaration of function `int ltoa(...)'
    :
    : line 105:
    : ltoa(long, string[100], 10);
    :
    : thanks,
    : matt
    :

  • hi!

    i'm calling the function, iam not declaring it. and i dont put
    type names in it. i just wrote it to explain which types i use in function.

    problem is: on my computer (compiled with my compilator) program is
    working without error messages. but i have to give it to
    my professor. and i can test it on the professor's server - i send
    my standart named cpp file and this server returned that error or
    warnig. i dont know what compiler use professor.

    matt.


    : Well, it depends. Are you declaring the function or calling it?
    : If you are calling it, don't put the type names in. "long" is a
    : type name, I assume String is too.
    : If you are calling the function in your program, don't use variable names like "long" which is a key word.
    : If this is a declaration, then you must give the function return type and drop the constant "10".
    :
    :
    : : Hi!
    : :
    : : can anybody explain following error message:
    : :
    : : tmp/1388.cpp:105: implicit declaration of function `int ltoa(...)'
    : :
    : : line 105:
    : : ltoa(long, string[100], 10);
    : :
    : : thanks,
    : : matt
    : :
    :
    :

  • I've pretty sure your professor is using GCC (g++), which doesn't support ltoa. The ltoa function is non-standard, so you should never use it under the assumption that it'll work for someone else. I gave you a solution. If you'd like to use GCC in Windows you can download it as part of Cygwin or Dev C++.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories