Message "undefined reference to 'itoa'" when trying to use itoia function

0

I found in some sites people talked about using the itoa function to convert an integer into a string containing the number in binary format.

Code example that should do this:

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

int main(){

 int i = 5; // Valor a ser convertido
 char c[33]; // Onde vou guardar o valor convertido (use o tamanho 33)

 itoa(i, c, 2);  // converter na base 2, acredito que converta até base 32

 printf("%s\n", c);

 getchar();
}

My intention is to try to see the results of conversions before using in my program, but when I try to copy, I get the message:

Intheend,Ifoundtheheadfilethatcontainstheprototypeofthefunctionwasmissing,butaccordingtothesitesIconsulteditisinstdlib.h.

Ihavetriedtoaddsomelibrary,searchtheerrormessageamongotherthings.

Asotherexampleslikethe question also have a problem similar.

Does anyone know why the problem occurs and how to solve it? Thanks in advance.

    
asked by anonymous 15.09.2018 / 21:11

0 answers