How to convert string to int type in c

1

I tried to use itoa, but it seems that the platform uri does not accept, somebody could give me another way to convert from string to int

Here is the code I tried

itoa(n1, p1, 10);
    
asked by anonymous 30.01.2018 / 13:08

1 answer

2

If your idea is to convert string to int, you should use atoi :

char num[10] = "100";
int valor = atoi(num);

detail: In C there are specific functions, according to input and output data type:

  • atof () Conversion of string in float
  • atoi () Conversion of string to int
  • atol () Conversion of string to long
  • itoa () Conversion of int to string
  • ltoa () Conversion of long to string
30.01.2018 / 13:13