I have this piece of code:
#include <stdio.h>
#include <iostream>
int main(int n, char** args)
{
int i = 140;
char c = i;
int j = c;
printf("%d", j);
system("pause");
}
Output:
-116
As I understand, char c = i would assign the character which has ASCII code 140 to c, but I wonder what happened when assigning int j = c; after that and where does -116 value come from?
if I change char c = i; to unsigned char c = i; then the output is 140.
Is there anyway to get the value of j equal to 140 if I don't use unsigned here? (assumed that i >= 0 and i <= 255)