I have started learning C a couple of weeks ago, but I have the following question. Any 'char' variables can hold string values and numeric valued from -128 to 127. If it is unsigned it can hold numeric values from 0 to 255. So I want to make a program were you type a character, and the program returns the character but in ASCII number. Here is the code from that program, but once I compile it it gives me an error (compiler error):
unsigned char c; //character
int n; //number
printf("Input a character:");
printf("Its ASCII code is: %i\n",n);
Can anyone help me out and tell me where the error in the program is. Thanks.