mardi 22 janvier 2019

Is char unsigned or signed by default in c/c++ language? [duplicate]

why do I get -87 as output when the input is 1 b I don't seem to understand how is the code working??

#include<stdio.h>
int main()
{
    int t,n; char c; 
    scanf("%d",&t);
    while(t--)
    {
     scanf("%c ",&c); 
     n=(c-'a');
     printf("%d\n",n);
    }
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire