S
sophie
Whats going on here:
Read in a number as a string:
scanf("%s", &number);
number = 12345, for arguements sake
Print it like this its fine:
printf("number: %s\n", number);
print it like this it will print the first digit, ie '1':
printf("number 0 c: %c\n", number[0]);
print it like this it prints '49' for the 1st char!!! Why?:
printf("number: %d\n", (int)number[0]);
Whats going on, and how do i properly convert a char to an int????!!!
Read in a number as a string:
scanf("%s", &number);
number = 12345, for arguements sake
Print it like this its fine:
printf("number: %s\n", number);
print it like this it will print the first digit, ie '1':
printf("number 0 c: %c\n", number[0]);
print it like this it prints '49' for the 1st char!!! Why?:
printf("number: %d\n", (int)number[0]);
Whats going on, and how do i properly convert a char to an int????!!!