Hi,
There is one thing I am cofused about....
If I have a declareation say
char str[10];
Now if I want to change it to wchar so do I have to change it
like ....
wchar_t str[10]; or double the size? like
wchar_t str[20];
if yes then Why? char and wchar_t wont take care of it?
Thanks
TS 5 4712 Sa***********@gmail.com wrote:
Hi,
There is one thing I am cofused about....
If I have a declareation say
char str[10];
Now if I want to change it to wchar so do I have to change it
like ....
wchar_t str[10]; or double the size? like
wchar_t str[20];
The array size is the number of elements of that type. char str[10] is
an array of 10 char, wchar_t str[10] is an array of 10 wchar_t.
--
Ian Collins.
On Aug 18, 11:33*am, Ian Collins <ian-n...@hotmail.comwrote:
Samant.Tru...@gmail.com wrote:
Hi,
* There is one thing I am cofused about....
If I have a declareation say
* *char str[10];
Now if I want to change it to wchar so do I have to change it
like ....
* wchar_t str[10]; *or double the size? like
* wchar_t str[20];
The array size is the number of elements of that type. *char str[10] is
an array of 10 char, wchar_t str[10] is an array of 10 wchar_t.
--
Ian Collins.
Ok Good this is what I was thinking. Wanted confirm. Thank you.
On 18 Aug., 08:13, Samant.Tru...@gmail.com wrote:
Hi,
* There is one thing I am cofused about....
If I have a declareation say
* *char str[10];
Now if I want to change it to wchar so do I have to change it
like ....
* wchar_t str[10]; *or double the size? like
* wchar_t str[20];
if yes then Why? char and wchar_t wont take care of it?
They will. Note that you only specify the number of elements of the
array, not the number of bytes. Thus sizeof(char[10]) == 10, but
sizeof(wchar_t[10]) == 20!
It only gets more troublesome if you are using utf8 characters that
need more than one byte (though doubling the arrays will only lead to
unused space).
Regards,
Stuart
On Aug 18, 12:05*pm, dertop...@web.de wrote:
On 18 Aug., 08:13, Samant.Tru...@gmail.com wrote:
Hi,
* There is one thing I am cofused about....
If I have a declareation say
* *char str[10];
Now if I want to change it to wchar so do I have to change it
like ....
* wchar_t str[10]; *or double the size? like
* wchar_t str[20];
if yes then Why? char and wchar_t wont take care of it?
They will. Note that you only specify the number of elements of the
array, not the number of bytes. Thus sizeof(char[10]) == 10, but
sizeof(wchar_t[10]) == 20!
It only gets more troublesome if you are using utf8 characters that
need more than one byte (though doubling the arrays will only lead to
unused space).
Regards,
Stuart
Well then your suggesion would be double the size?? When I declare
char it is one byte and wchar_t it is 2 bytes, isn't that true?
So when I say char[10] it is 10 bytes so wchar_t[10] should be 20
bytes right??
Thanks
TS
On Aug 18, 6:49*am, "Samant.Tru...@gmail.com"
<Samant.Tru...@gmail.comwrote:
On Aug 18, 12:05*pm, dertop...@web.de wrote:
On 18 Aug., 08:13, Samant.Tru...@gmail.com wrote:
* There is one thing I am cofused about....
If I have a declareation say
* *char str[10];
Now if I want to change it to wchar so do I have to change it
like ....
* wchar_t str[10]; *or double the size? like
* wchar_t str[20];
if yes then Why? char and wchar_t wont take care of it?
They will. Note that you only specify the number of elements of the
array, not the number of bytes. Thus sizeof(char[10]) == 10, but
sizeof(wchar_t[10]) == 20!
It only gets more troublesome if you are using utf8 characters that
need more than one byte (though doubling the arrays will only lead to
unused space).
Well then your suggesion would be double the size?? When I declare
char it is one byte and wchar_t it is 2 bytes, isn't that true?
So when I say char[10] it is 10 bytes so wchar_t[10] should be 20
bytes right??
Not necessarily. On some systems (OS X comes to mind) the size of
wchar_t is four bytes. In that case, a wchar_t[10] array requires 40
bytes of storage - or quadruple the amount of memory needed to store a
char[10] array..
Greg This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bren |
last post by:
Hi all,
I wonder if anyone knows of a string class out there that can do on
demand conversion from wchar_t to char?
We are writing an app that will need to be localized and cross
platform. ...
|
by: Mark Fancy |
last post by:
I have a project that I'm trying to get to compile. I
need to have the /Tc:wchar_t compile switch in order to
use some libraries. I have included the following header
files:
#include <mapix.h>...
|
by: Frank R Eid |
last post by:
Hi all;
A) What's the simplest way to convert a 'String' to 'char *' (and the other
way araound) ?
B) I have some C++ classes that I cannot easily convert to .NET (because
they still are...
|
by: Marcin Kalicinski |
last post by:
wchar_t c1 = wchar_t('A');
wchar_t c2 = L'A';
Is c1 equal to c2?
If they are not equal, how can I create wchar_t character representing the
same character as some char value?
cheers,...
|
by: Alejandro Aleman |
last post by:
Hello!
i know this may be a newbie question, but i need to convert a string from
System::String^ to char*, in the msdn page tells how, but i need to set to
/clr:oldSyntax and i dont want it...
|
by: Marcin Kalicinski |
last post by:
Are 3 types: signed char, char and unsigned char distinct? My compiler is
treating char as signed char (i.e. it has sign, and range from -128 to 127),
but the following code does not call f<char>...
|
by: MattWilson.6185 |
last post by:
Hello!
I am trying to convert a char * to a LPWSTR, and I am going absolutly
mad! I can't find anything besides typle L"string" Unfortunetaly I
can't use that...
basicaly the setup is
...
|
by: Dancefire |
last post by:
Hi, everyone,
I'm writing a program using wstring(wchar_t) as internal string.
The problem is raised when I convert the multibyte char set string
with different encoding to wstring(which is...
|
by: Michael Brennan |
last post by:
I guess this question only applies to programming applications for UNIX,
Windows and similiar. If one develops something for an embedded system
I can understand that wchar_t would be unnecessary.
...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |