Use sscanf to convert:
#include
int main(){
int a;
char s[]="2";
sscanf(s,"%d",&a); //The reading format is converted to integer using %d
printf("%d\n",a);
return 0;
}
Output integer value 2