how many characters can wchar and char have?

how many characters can wchar and char have in win32?

how many characters can wchar and char have in 64-bit windows ?

thanks
What?

Stick to one thread for the same topic, please.

A character is always a single character.

A linear collection of characters is a string -- which can have as many characters in it as you want (within reasonable limits).


A char is an 8-bit entity -- good for ASCII and various multilingual code pages.
A wchar_t is a 16- or 32-bit entity (depending on your platform and compiler) -- good for things like Unicode.

Hope this helps.
thanks ,


A linear collection of characters is a string -- which can have as many characters in it as you want (within reasonable limits).


that means wchar_t can have 100 character, right?

100 characters = 100 byte, right?

string cur_dir ;
int success = GetCurrentDirectory(65,cur_dir );
can i use this ?
the format of api- GetCurrentDirectory is
GetCurrentDirectory
(
__in DWORD nBufferLength,
__out LPTSTR lpBuffer
);


how many bytes of a chinese word?
thanks again

Last edited on
Ah, you're translating from Chinese? No wonder you're having trouble with the technical translation...

By "linear collection" I meant an array. An array is usually written with each element in the array written separately:
const char name[ 6 ] = { 'M', 'u', 'l', 'a', 'n', '\0' };

However, with character strings ('string' is another word for 'array', except that in C we typically mean an array of char), we can use a shortcut and just write it in double quotes ("):
const char name[ 6 ] = "Mulan";

Remember what I wrote:
A char is an 8-bit entity -- good for ASCII and various multilingual code pages.
A wchar_t is a 16- or 32-bit entity (depending on your platform and compiler) -- good for things like Unicode.

In either case, the value represents a single character.

If you want more than one character, you must have an array of characters. Since you are using Chinese, you want to use wchar_t, since it can be used to display Chinese mesographs (because char cannot).

In C:
const wchar_t name[ 4 ] = L"花木蘭";

In C++:
wstring name( L"花木蘭" );

Hope this helps.
thanks, it help
i found out 1 Byte = 8 bit~ ~

and how long can a variable name be ?
Last edited on
An identifier may be any length, but you shouldn't assume any more than 30 characters are significant.
There isn't a maximum length for variable names in C++ but too long names can lead to some problems:
http://www.cplusplus.com/forum/lounge/10994/
There isn't a maximum length for variable names in C++

The rest of an environment, such as the linker, may have some limit, I believe.
Last edited on
Topic archived. No new replies allowed.