It says there's no itoa. Why?

Asked 2 years ago, Updated 2 years ago, 125 views

http://www.cplusplus.com/reference/cstdlib/itoa/?kw=itoa I used the example here, but it says there's no itoa.

What's wrong with you?

itoa doesn't exist

#include <stdio.h>
#include <stdlib.h>

int main ()
{
    int i;
    char buffer [33];
    printf ("Enter a number: ");
    scanf ("%d",&i);
    itoa (i,buffer,10);
    printf ("decimal: %s\n",buffer);
    itoa (i,buffer,16);
    printf ("hexadecimal: %s\n",buffer);
    itoa (i,buffer,2);
    printf ("binary: %s\n",buffer);
    return 0;
}

type-conversion string c itoa integer

2022-09-21 14:54

1 Answers

Because itoa is not a standard function. Depending on the development environment, it may or may not be itoa.

Write sprintf() instead of itoa.

int aInt = 368;
char str[15];
sprintf(str, "%d", aInt);


2022-09-21 14:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.