There is a new book-ish like entity that is freely available on the web:
"Constructs of the C++ Proramming Language"
The book is intended to serve as a light-weight reference for developers
with modest experience in C++.
Enjoy,
Landrew 4 1305
Doh!
To be found at www.landrew.com
"Landrew" <ne****@landrew.com> wrote in message
news:td********************@speakeasy.net... There is a new book-ish like entity that is freely available on the web:
"Constructs of the C++ Proramming Language"
The book is intended to serve as a light-weight reference for developers with modest experience in C++.
Enjoy, Landrew
Landrew wrote: "Constructs of the C++ Proramming Language"
To be found at www.landrew.com
Cool! Thanks! http://www.landrew.com/cgi-bin/Via/E...tructs/Strings
says: void process() { char s[100] = "hop on!"; }
The first seven positions in s are set to 'h', 'o', 'p', ' ' (space), 'o', 'n', '!'. The eigth position is set to a special end of string marker, called the null character. The null character is denoted by '\0' when it explicitly appears in code.
s[8] to s[99] are set to a null character as well.
Thus the code above has the same effect as the following:
void process() { char s[100];
s[0] = 'h'; s[1] = 'o'; s[2] = 'p'; s[3] = ' '; s[4] = 'o'; s[5] = 'n'; s[6] = '!'; s[7] = '\0'; // end of string marker (null character) }
This version will leave s[8] to s[99] uninitialized. Also it might take
less memory during runtime, because it won't store this literal string,
"hop on!".
Regards,
Niels Dekker http://www.xs4all.nl/~nd/dekkerware
> s[8] to s[99] are set to a null character as well.
interesting. are you certain about that? i would have thought it would be
true for global variables, but not for local variables.
just as this initializes x to zero
----
int x;
int main()
{
...
}
----
but this does not
----
int main()
{
int x;
...
}
----
at least that is what i thought :)
landrew
"Niels Dekker - no reply address" <un*****@this.is.invalid> wrote in message
news:41***************@this.is.invalid... Landrew wrote: "Constructs of the C++ Proramming Language"
To be found at www.landrew.com
Cool! Thanks! http://www.landrew.com/cgi-bin/Via/E...tructs/Strings says: void process() { char s[100] = "hop on!"; }
The first seven positions in s are set to 'h', 'o', 'p', ' ' (space), 'o', 'n', '!'. The eigth position is set to a special end of string marker, called the null character. The null character is denoted by '\0' when it explicitly appears in code.
s[8] to s[99] are set to a null character as well.
Thus the code above has the same effect as the following:
void process() { char s[100];
s[0] = 'h'; s[1] = 'o'; s[2] = 'p'; s[3] = ' '; s[4] = 'o'; s[5] = 'n'; s[6] = '!'; s[7] = '\0'; // end of string marker (null character) }
This version will leave s[8] to s[99] uninitialized. Also it might take less memory during runtime, because it won't store this literal string, "hop on!".
Regards,
Niels Dekker http://www.xs4all.nl/~nd/dekkerware www.landrew.com says: void process() { char s[100] = "hop on!"; }
The first seven positions in s are set to 'h', 'o', 'p', ' ' (space), 'o', 'n', '!'. The eigth position is set to a special end of string marker, called the null character. The null character is denoted by '\0' when it explicitly appears in code.
And I commented: s[8] to s[99] are set to a null character as well.
Landrew wrote: interesting. are you certain about that?
Well... home.tiscalinet.ch/t_wolf/tw/c/string_init.html says: yes, if a string literal in an initializer contains less characters than the array has elements, the remaining elements are set to 0.
I guess the same holds in C++.
Regards,
Niels Dekker http://www.xs4all.nl/~nd/dekkerware This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: masood.iqbal |
last post by:
My simplistic mind tells me that having local variables within looping
constructs is a bad idea. The reason is that these variables are
created during the beginning of an iteration and deleted at...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: Marcos MOS |
last post by:
Hi,
I've put a appSetting tag into my web.config, but when I try to catch its
value to my Image WebControl occurs the follow error: "Server tags cannot
contain <% ... %> constructs."
on...
|
by: Martin Schmid |
last post by:
I'm getting a parser error message:
Server tags cannot contain <% ... %> constructs...
Ok.. so How do I accomplish this:
For Each file in Files
if ucase(right(file.name,7))<>ucase("_tn.jpg")...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: Neil Zanella |
last post by:
Hello,
I would like to do the following:
<form method="post"
action="<%= Request.ServerVariables %>"
runat="server">
The reason I would like to do this is twofold:
|
by: portroe |
last post by:
What would be a typical scenario or real-world reason to us Overload
constructs,
thanks
portroe
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |