Here is a simple program which gives me unexpected results:
int main()
{
printf("\nTo calculate a^b, enter value a now.\n");
int a = getchar() - '0';
printf("\nEnter b now.\n");
int b = getchar() - '0';
printf("a = %d, b = %d\n\n", a, b);
return 0;
}
if i hit a digit for a, then hit enter, it assigns -38 as the value of b.
the only way it works is if i enter a and b right next to each other, such as 52. this is not how i want it to behave. your advice greatly appreciated!