#include<stdio.h>
void main()
{
char a = 'AB';
printf("%c", a);
}
// In the above program why the output is 'B';
Here we are assigning 'AB' to a char and there's no compiler error.
Printable View
#include<stdio.h>
void main()
{
char a = 'AB';
printf("%c", a);
}
// In the above program why the output is 'B';
Here we are assigning 'AB' to a char and there's no compiler error.
First use Code tags!
Second, try to avoid empty lines is such a short snippet.
Third, what compiler are you using? My VC2010 shows the following warnings:Is it clear now?Code:d:\2010 projects\...: warning C4305: 'initializing' : truncation from 'int' to 'char'
d:\2010 projects\...: warning C4309: 'initializing' : truncation of constant value
Start with reading C++ Character Constants which 'AB' really is.Quote:
// In the above program why the output is 'B';