0

Hello All!

I am trying to do something simple. Which is why our application is failing miserably;)

Anyway, I am attempting to use the itoa() - integer to ASCII function to convert an
integer value, lets say 123 into "123".

The code compiles successfully, however during the linking, it says undefined symbol "itoa". I did a search and found that the itoa() function is a non-standard implementation.

Can someone please assist? I remember sscanf or sprintf, and have used sprintf, but it
was unsuccessful.

Thanks in advance for your help!

2
Contributors
4
Replies
6
Views
9 Years
Discussion Span
Last Post by Radical Edward
0

Does your sprintf call look like this?

#include <stdio.h>

int main(void)
{
  int x = 123;
  char s[4]; /* Enough room for "123" +1 for null character */

  sprintf(s, "%d", x);
  puts(s);

  return 0;
}

How exactly was it unsuccessful for you?

0

Radical Edward:

I found the problem thanks to your example! I had done the following:

sprintf(char_buffer, [B]"%s"[/B], integer_value);

I used "%s" whereas I should have used "%d"....

Edited by happygeek: fixed formatting

1

> I found the problem thanks to your example!
Woohoo! :) Just remember that sprintf and sscanf are exactly the same as fprintf and fscanf except they use strings instead of files. That's how Ed keeps things straight in her head.

Votes + Comments
Gave a great answer to a simple problem.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.