0

Hi how to modify character size as 2 bytes in C ? because the size of character in C is 1 byte only

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
Ramakrishna
  • 163
  • 3
  • 9
  • 2
    http://stackoverflow.com/questions/12643580/how-do-i-use-3-and-4-byte-unicode-characters-with-standard-c-strings][1] Check This Link – Sathish Feb 25 '14 at 14:32

5 Answers5

0

No it is not possible. You cannot modify the character size to 2 bytes as the size of character is set to 1 byte by default. You cannot modify the data types. You can probably use a array of characters to store more than one character like:

char s[10];

On a side note:-

From here

enter image description here

Size qualifiers alter the size of the basic data types. There are two size qualifiers that can be applied to integer: short and long. The minimum size of short int is 16 bit. The size of int must be greater than or equal to that of a short int. The size of long int must be greater than or equal to a short int. The minimum size of a long int is 32 bits.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

You can't change any data type size. You need to change the data type depending on the values you are going to store..

If you need to store more than one character,use the array of character as below..

char a[2];

In above declaration variable 'a' will hold string of two characters..

Haji
  • 1,999
  • 1
  • 15
  • 21
0

You can use unsigned short. You cannot modify the data types.

user376507
  • 2,004
  • 1
  • 19
  • 31
0

You can do as following,

typedef unsigned short newChar;
int main() 
{
   newChar c = 'a';
}
Subhajit
  • 320
  • 1
  • 6
0

C uses Ascii format of storing characters, so the range of these ASCII characters 0-255. 0-127 are general ascii character set. 127 onwards is extended set. So C supports 1 byte characters only. Whereas Java uses unicodes, which has a larger range, so the storage in Java for characters could be greater than 1 byte.