|
-
June 11th, 2012, 03:34 AM
#1
C_program
#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.
TANUSHREE-AGRAWAL...
-
June 11th, 2012, 03:56 AM
#2
Re: C_program
 Originally Posted by Tanushreeagr
Code:
#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:
Code:
d:\2010 projects\...: warning C4305: 'initializing' : truncation from 'int' to 'char'
d:\2010 projects\...: warning C4309: 'initializing' : truncation of constant value
Is it clear now?
Victor Nijegorodov
-
June 11th, 2012, 08:23 AM
#3
Re: C_program
// In the above program why the output is 'B';
Start with reading C++ Character Constants which 'AB' really is.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|