xxxxxxxxxx
int arg1 = atoi(argv[1]); //argv[0] is the program name
//atoi = ascii to int
xxxxxxxxxx
strcpy(str, "98993489");
val = atoi(str);
printf("String value = %s, Int value = %d\n", str, val);
xxxxxxxxxx
Use ASCII chart.
int i=65;
char ch;
ch= (char)i;
printf("Expected value of ch: A. This value is found by using a ASCII chart");
xxxxxxxxxx
#include <stdio.h>
#include <stdlib.h>
int main() {
char c = '7';
int i = atoi(&c);
printf("Character '%c' as an integer: %d\n", c, i);
return 0;
}
xxxxxxxxxx
char a = 'a';
int ia = (int)a;
/* note that the int cast is not necessary -- int ia = a would suffice */
char a = '4';
int ia = a - '0';
/* check here if ia is bounded by 0 and 9 */