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!

Recommended Answers

All 4 Replies

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?

Radical Edward:

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"....

> 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.

commented: Gave a great answer to a simple problem. +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.