Character Data Type
C
stores character type internally as an integer. Each character has 8 bits so we
can have 256 different characters values (0-255).
Character
set is used to map between an integer value and a character. The most common
character set is ASCII.
Let
take a look at example of using a variable which hold character 'A'.
#include<stdio.h>
void main()
|
||
{
|
char ch = 'A';
|
||
printf("%c\n",ch);
|
ch = 65;// using integer
representation
|
||
printf("%c\n",ch);
|
ch = '\x41'; //
using hexadecimal representation
|
||
printf("%c\n",ch);
|
ch = '\101'; //
using octal representation
|
||
printf("%c\n",ch);
|
}
|
Here is
the output
A
A
A
A
A
A
A
No comments:
Post a Comment