Deep wrote:
Suppose there is a character of one byte then max characters possible
under this are 256.
Not true. A byte or char has CHAR_BIT bits, and can have
pow(2,CHAR_BIT) states. That number need not, and in many cases is not 256.
If characters are of two bytes then max chars should be 65536.
Not true. The world is not defined by the toy box in front of you.
Now if character can be of one byte or two byte then how many
characters are possible and why?
Suppose you have a two-byte sequence representing a single character
byte1:byte2
How do you know that this is not a two character sequence? The easiest
way is to have some bit which is never set or always set in a single
byte character. Suppose that it is always set for the first byte of a
two byte character and never set for a single byte character.
Then you can have
pow(2,CHAR_BIT-1) single byte characters and
pow(2,2*CHAR_BIT-1) two byte characters.
>
Also write a program to read and write characters in such type of
encoding.
Would you people help me to do this?
I've already given you more help than you deserve. Show us some code
and describe your problem, and we may be able to help you fix it.
Always try to do your own homework. None of us wants to depend on
someone who cheated his way through school.