I found out that wchar_t has 2 byte but don't know how to use this
I am using windows and compiler is Borland 5.02 I am learner so plz don't say anything about compiler I just need help in this.
You could also do an array/vector of a custom object/class that you create that stores two chars or a string =p but probably more work than is needed since a string should get the job done.
I found out that wchar_t has 2 byte but don't know how to use this
On Windows, wchar_t is for 2-byte character sets (i.e. 16-bit Unicode), not for storing two normal chars, e.g.
constchar msg[] = "Hello world!"; // normal chars
constwchar_t wmsg[] = L"Hello wide world!"; // Unicode chars (L for long, I suppose.)
Here msg is 13 bytes long (inc. null terminator), whereas wmsg is 26 bytes long.
Note that wchar_t is usually 32-bits on Linux systems (as they use 32-bit Unicode.)
i need 2 byte char type so I can store A+ in array
Do you mean a fixed set of strings, or do you need to change them?
compiler is Borland 5.02
You're using a compiler from 1997? You might want to consider obtaining a new compiler (and IDE). It certaining won't understand the C++11 code that JLBorges posted. (Edit: after looking at the code properly and seeing it isn't C++11.)
You're using a compiler from 1997? You might want to consider obtaining a new compiler (and IDE). It certaining won't understand the C++11 code that JLBorges posted.
Last time I checked (with the freeware version 5.5) it doesn't fully support C++98. That's not to say it was all bad, it appeared to be heavily optimized for speed (at least on old machines).
On topic, I was going to post a suggestion to use an array of pointers to const char but then I refreshed and saw JLBorges' reply, so...