String to integer
This tip submitted by Mayur Avhad on 2005-02-08 23:55:27. It has been viewed 23679 times.
Rating of 6.0 with 276 votes
You can use sscanf to convert a string to an integer:
#include
int main()
{
char *str="12";
int i;
sscanf(str, "%d", &i);
printf("%d\n", i);
return 0;
}
More tips
Help your fellow programmers! Add a tip!