473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

a question about constant

Why the value of 'ab\0\0' is 0x00616200, rather than 0x61620000 ?
The workset is win2k + VC6.

Any help would be appreciated.

Thanks.

CJ

Aug 11 '06 #1
5 1144
"phoenix_keeper" <m.**************@gmail.comwrites:
Why the value of 'ab\0\0' is 0x00616200, rather than 0x61620000 ?
The workset is win2k + VC6.

Any help would be appreciated.
The value of any character constant containing more than one character
is implementation-defined. You should consult the documentation for
your compiler. Better yet, you should avoid using such character
constants; they're extremely non-portable.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 11 '06 #2
phoenix_keeper wrote:
Why the value of 'ab\0\0' is 0x00616200, rather than 0x61620000 ?
The workset is win2k + VC6.

Any help would be appreciated.

Thanks.

CJ
Research the term "Little Endian".
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Aug 11 '06 #3

phoenix_keeper wrote:
Why the value of 'ab\0\0' is 0x00616200, rather than 0x61620000 ?
The workset is win2k + VC6.
Because that's the value that the compiler you are using chose to give
it. The value of a character constant containing more than one
character is defined by the implementation. The algorithm they use is
supposed to be specified in the compiler's documentation. If you want
to know why they chose the algorithm they did, you'll have to ask the
maker of the compiler.

Aug 11 '06 #4

"Thomas Matthews" <Th***************@cox.networkwrote in message
news:44**************@cox.network...
phoenix_keeper wrote:
Why the value of 'ab\0\0' is 0x00616200, rather than 0x61620000 ?
The workset is win2k + VC6.

Any help would be appreciated.

Thanks.

CJ

Research the term "Little Endian".
No...

Let's ignore for a moment the fact that it is a character constant and not a
string constant, as KT pointed out.

The last value in the OP's question: 0x61620000 is "Big Endian." But, the
first value(0x00616200) is _neither_ "Little Endian" (0x00006261) or "Big
Endian" (0x61620000) (as they are currently defined, i.e, no remarks on PDPs
please...). The fact that his value 0x00616200 has 'a' before 'b' and isn't
properly "Big Endian", indicates something else is going on (see KTs post).
Rod Pemberton
Aug 11 '06 #5
yeah, Thank you all :)

Aug 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Dmitry D | last post by:
Hi, I'm new to C++ (started learning in the beginning of this summer), and I have the following question (sorry if it sounds stupid): In many code samples and source files, I see NULL expression...
14
by: Fred H | last post by:
I'm reading a STL book right now, and there I've picked up the folowing syntax: class C { private: int value; public: C(int initValue) : value(initValue) { } }
8
by: john smith | last post by:
I have a question about the best way to use constants in C++. There seem to be variations in the way that they are used, and I am confused as to what I should be using. Basically since the...
0
by: David W. Fenton | last post by:
Today I was working on a hideous old app that I created a long time ago that does a lot of showing/hiding/resizing of fields on one of the forms. I had used constants to store reference values for...
6
by: Prasad | last post by:
Where are the const variables actually stored in memory. I mean If they are stored in data segment(external & static variables)or stack segment(local) how the compiler knows that it is read only...
50
by: Joseph Casey | last post by:
Greetings. I have read that the mistake of calling free(some_ptr) twice on malloc(some_data) can cause program malfunction. Why is this? With thanks. Joseph Casey.
7
by: Bala L | last post by:
I have a class with a private array data member 'm_array'. I have written a public function, called 'fileRead', to read values into the array from a file. I just noticed that I have declared this...
3
by: mimi | last post by:
1.Instead of using macro, I would like to use static const variables in such situations. class Foo { public: static const int SOMEVALUEWITHFOO = 1; } int main() {
20
by: liujiaping | last post by:
I'm confused about the program below: int main(int argc, char* argv) { char str1 = "abc"; char str2 = "abc"; const char str3 = "abc"; const char str4 = "abc"; const char* str5 = "abc";
6
by: comp.lang.c++ | last post by:
this is a sample example about this question #include<stdio.h> void chg(char* t) { char *s=t; char p=*t; while(*t++=*++s); *--t=p; } int main()
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.