f



Changing case "message" to "MESSAGE"

Working my way through Koenig & Moo "Accelerated C++" and using 
Borlang Builder 5 (but that is probably not relevant) I reached 
exercise 1-1 and typed in

#include <vcl.h>
#pragma hdrstop
#include <iostream>
#include <string>

int main(int argc, char*argv[]}
{
const std::string hello = "Hello" // This by itself compiled
const std::string message = "Hello" // and other stuff which I have     
                                    //left out here.
system("PAUSE");
return 0;

}

But I left caps lock on, and by mistake typed MESSAGE, and it didn't 
compile. I retyped message in lower case it did compile! I was 
astonished. I thought you could give variables any name you liked, 
capitalised or not.

What's the explanation? Is MESSAGE a reserved word?

Michael Bell

-- 
0
michael104 (366)
11/15/2007 3:49:03 PM
comp.lang.c++ 49423 articles. 7 followers. Post Follow

13 Replies
1034 Views

Similar Articles

[PageSpeed] 23

On 2007-11-15 10:49:03 -0500, Michael Bell <michael@beaverbell.co.uk> said:

> 
> But I left caps lock on, and by mistake typed MESSAGE, and it didn't
> compile. I retyped message in lower case it did compile! I was
> astonished. I thought you could give variables any name you liked,
> capitalised or not.
> 
> What's the explanation? Is MESSAGE a reserved word?
> 

No. It's probably a macro that's defined in "vcl.h".

-- 
  Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The 
Standard C++ Library Extensions: a Tutorial and Reference 
(www.petebecker.com/tr1book)

0
pete2666 (1733)
11/15/2007 3:52:50 PM
Michael Bell wrote:
> Working my way through Koenig & Moo "Accelerated C++" and using
> Borlang Builder 5 (but that is probably not relevant) I reached
> exercise 1-1 and typed in
>
> #include <vcl.h>
> #pragma hdrstop
> #include <iostream>
> #include <string>
>
> int main(int argc, char*argv[]}
> {
> const std::string hello = "Hello" // This by itself compiled
> const std::string message = "Hello" // and other stuff which I have
>                                    //left out here.
> system("PAUSE");
> return 0;
>
> }
>
> But I left caps lock on, and by mistake typed MESSAGE, and it didn't
> compile. I retyped message in lower case it did compile! I was
> astonished. I thought you could give variables any name you liked,
> capitalised or not.
>
> What's the explanation? Is MESSAGE a reserved word?

First, I don't see any "MESSAGE" used in your text.

Second, why do you need 'argc' and 'argv' if you're not using them?

Third, I doubt Koenig's book recommends <vcl.h> or hdrstop pragma,
what if you just drop those?

Forth, every declaration statement need to end with a semicolon.

Fifth, 'MESSAGE' (if you did in fact use it somewhere) _can_ be
a macro in your compiler's environment.

V
-- 
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask 


0
v.Abazarov (13256)
11/15/2007 3:53:30 PM
In message <2007111510525016807-pete@versatilecodingcom>
          Pete Becker <pete@versatilecoding.com> wrote:

> On 2007-11-15 10:49:03 -0500, Michael Bell <michael@beaverbell.co.uk> said:

>> 
>> But I left caps lock on, and by mistake typed MESSAGE, and it didn't
>> compile. I retyped message in lower case it did compile! I was
>> astonished. I thought you could give variables any name you liked,
>> capitalised or not.
>> 
>> What's the explanation? Is MESSAGE a reserved word?
>> 

> No. It's probably a macro that's defined in "vcl.h".

I was unable to test this theory because it won't complile without 
#include <vcl.h> at the top - the error message gives a linker error 
and quotes vcl.h. And I can't trace A macro "MESSAGE" in "Borland 
Builder C++ 5 for Dummies" - but that's not proof.

It doesn't matter too much. I can still get on with the book. But I 
don't like it when something happens that I don't understand. But your 
suggestion allows me to lay that worry aside.

Michael Bell
-- 
0
michael104 (366)
11/15/2007 5:32:36 PM
In message <fhhq1r$fqo$1@news.datemas.de>
          "Victor Bazarov" <v.Abazarov@comAcast.net> wrote:

> Michael Bell wrote:
>> Working my way through Koenig & Moo "Accelerated C++" and using
>> Borlang Builder 5 (but that is probably not relevant) I reached
>> exercise 1-1 and typed in
>>
>> #include <vcl.h>
>> #pragma hdrstop
>> #include <iostream>
>> #include <string>
>>
>> int main(int argc, char*argv[]}
>> {
>> const std::string hello = "Hello" // This by itself compiled
>> const std::string message = "Hello" // and other stuff which I have
>>                                    //left out here.
>> system("PAUSE");
>> return 0;
>>
>> }
>>
>> But I left caps lock on, and by mistake typed MESSAGE, and it didn't
>> compile. I retyped message in lower case it did compile! I was
>> astonished. I thought you could give variables any name you liked,
>> capitalised or not.
>>
>> What's the explanation? Is MESSAGE a reserved word?

> First, I don't see any "MESSAGE" used in your text.

I quoted it in the correct, lower case.

> Second, why do you need 'argc' and 'argv' if you're not using them?

Borland loads them by default. It runs even it I remove them. I have 
no idea what they do.

> Third, I doubt Koenig's book recommends <vcl.h> or hdrstop pragma,
> what if you just drop those?

> Forth, every declaration statement need to end with a semicolon.

Yes, I missed them out. But they were there.

> Fifth, 'MESSAGE' (if you did in fact use it somewhere) _can_ be
> a macro in your compiler's environment.

I can't trace it in "Borland Builder C++ 5 for Dummies." But at least 
I know that I haven't misunderstood the main meat of the lessons.

Michael Bell

-- 
0
michael104 (366)
11/15/2007 5:36:47 PM
Michael Bell wrote:
> Working my way through Koenig & Moo "Accelerated C++"

> system("PAUSE");

  If that book really teaches you to do that, throw it away and buy a
better one.
0
nospam270 (2948)
11/15/2007 6:40:38 PM
Juha Nieminen wrote:
> Michael Bell wrote:
>> Working my way through Koenig & Moo "Accelerated C++"
>
>> system("PAUSE");
>
>  If that book really teaches you to do that, throw it away and buy a
> better one.

Nah...  Just caint be.  But a better compiler or IDE might actually
serve Michael well.

V
-- 
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask 


0
v.Abazarov (13256)
11/15/2007 6:43:27 PM
In message <473c929c$0$3198$39db0f71@news.song.fi>
          Juha Nieminen <nospam@thanks.invalid> wrote:

> Michael Bell wrote:
>> Working my way through Koenig & Moo "Accelerated C++"

>> system("PAUSE");

>   If that book really teaches you to do that, throw it away and buy a
> better one.

That's in "C++ for Dummies". Koenig and Moo assume that somebody who 
knows what he is doing has set your computer up for you. If you run 
their programs as they show on the page, the .exe opens and closes in 
a tenth of a second. You've got to do something to hold it there long 
enough to see it. If you think this is bad, what should I do better/

Michael Bell


-- 
0
michael104 (366)
11/15/2007 7:22:45 PM
Michael Bell wrote:
> In message <473c929c$0$3198$39db0f71@news.song.fi>
>           Juha Nieminen <nospam@thanks.invalid> wrote:
> 
>> Michael Bell wrote:
>>> Working my way through Koenig & Moo "Accelerated C++"
> 
>>> system("PAUSE");
> 
>>   If that book really teaches you to do that, throw it away and buy a
>> better one.
> 
> That's in "C++ for Dummies". Koenig and Moo assume that somebody who 
> knows what he is doing has set your computer up for you. If you run 
> their programs as they show on the page, the .exe opens and closes in 
> a tenth of a second. You've got to do something to hold it there long 
> enough to see it. If you think this is bad, what should I do better/

Use the command line version of the compiler.
0
no.spam9 (2339)
11/15/2007 8:03:55 PM
On 2007-11-15 20:22, Michael Bell wrote:
> In message <473c929c$0$3198$39db0f71@news.song.fi>
>           Juha Nieminen <nospam@thanks.invalid> wrote:
> 
>> Michael Bell wrote:
>>> Working my way through Koenig & Moo "Accelerated C++"
> 
>>> system("PAUSE");
> 
>>   If that book really teaches you to do that, throw it away and buy a
>> better one.
> 
> That's in "C++ for Dummies". Koenig and Moo assume that somebody who 
> knows what he is doing has set your computer up for you. If you run 
> their programs as they show on the page, the .exe opens and closes in 
> a tenth of a second. You've got to do something to hold it there long 
> enough to see it. If you think this is bad, what should I do better/

If you use Visual C++ 2005 Express you can use Ctrl+F5 when running your
program to get a command windows that does not disappear. If you use
another IDE look into making it run a bat-file which launches the
application and then pauses instead of running the application directly.

-- 
Erik Wikström
0
Erik-wikstrom (1881)
11/15/2007 10:31:11 PM
"Michael Bell" <michael@beaverbell.co.uk> wrote in message 
news:6d783c424f.michaelbell@michael.beaverbell.co.uk...
> In message <2007111510525016807-pete@versatilecodingcom>
>          Pete Becker <pete@versatilecoding.com> wrote:
>
>> On 2007-11-15 10:49:03 -0500, Michael Bell <michael@beaverbell.co.uk> 
>> said:
>
>>>
>>> But I left caps lock on, and by mistake typed MESSAGE, and it didn't
>>> compile. I retyped message in lower case it did compile! I was
>>> astonished. I thought you could give variables any name you liked,
>>> capitalised or not.
>>>
>>> What's the explanation? Is MESSAGE a reserved word?
>>>
>
>> No. It's probably a macro that's defined in "vcl.h".
>
> I was unable to test this theory because it won't complile without
> #include <vcl.h> at the top - the error message gives a linker error
> and quotes vcl.h. And I can't trace A macro "MESSAGE" in "Borland
> Builder C++ 5 for Dummies" - but that's not proof.
>
> It doesn't matter too much. I can still get on with the book. But I
> don't like it when something happens that I don't understand. But your
> suggestion allows me to lay that worry aside.

So opne up hte file vcl.h and search for MESSAGE 


0
tazmaster (2359)
11/16/2007 12:04:32 AM
In message <o85%i.123$_X2.18@newsfe06.lga>
          "Jim Langston" <tazmaster@rocketmail.com> wrote:

> "Michael Bell" <michael@beaverbell.co.uk> wrote in message
> news:6d783c424f.michaelbell@michael.beaverbell.co.uk...
>> In message <2007111510525016807-pete@versatilecodingcom>
>>          Pete Becker <pete@versatilecoding.com> wrote:
>>
>>> On 2007-11-15 10:49:03 -0500, Michael Bell <michael@beaverbell.co.uk>
>>> said:
>>
>>>>
>>>> But I left caps lock on, and by mistake typed MESSAGE, and it didn't
>>>> compile. I retyped message in lower case it did compile! I was
>>>> astonished. I thought you could give variables any name you liked,
>>>> capitalised or not.
>>>>
>>>> What's the explanation? Is MESSAGE a reserved word?
>>>>
>>
>>> No. It's probably a macro that's defined in "vcl.h".
>>
>> I was unable to test this theory because it won't complile without
>> #include <vcl.h> at the top - the error message gives a linker error
>> and quotes vcl.h. And I can't trace A macro "MESSAGE" in "Borland
>> Builder C++ 5 for Dummies" - but that's not proof.
>>
>> It doesn't matter too much. I can still get on with the book. But I
>> don't like it when something happens that I don't understand. But your
>> suggestion allows me to lay that worry aside.

> So opne up hte file vcl.h and search for MESSAGE

I can't search vcl.h itself, or at least I don't know how to, but I 
have searched the help for it, and there is a macro called "MESSAGE" 
(UPPER CASE) so your suspicions are well founded and I know how I have 
tripped over an obstacle that I had no reason to suspect was there. 
All sorted then. Thank you everybody.

Michael Bell




-- 
0
michael104 (366)
11/16/2007 10:18:08 AM
On Nov 15, 8:22 pm, Michael Bell <mich...@beaverbell.co.uk> wrote:
> In message <473c929c$0$3198$39db0...@news.song.fi>
>           Juha Nieminen <nos...@thanks.invalid> wrote:

> > Michael Bell wrote:
> >> Working my way through Koenig & Moo "Accelerated C++"
> >> system("PAUSE");
> >   If that book really teaches you to do that, throw it away and buy a
> > better one.

> That's in "C++ for Dummies". Koenig and Moo assume that
> somebody who knows what he is doing has set your computer up
> for you. If you run their programs as they show on the page,
> the .exe opens and closes in a tenth of a second. You've got
> to do something to hold it there long enough to see it. If you
> think this is bad, what should I do better/

Find out how to use your IDE?  Or use a different one?  Erik
Wikstr=F6m has posted how to use Visual Studio correctly.  If
you're IDE doesn't have something similar, it's time to change
it (and Visual Studio is free, as are some others).

(Once you start programming professionally, of course, you'll
drop the IDE in favor of more powerful tools.  But while
learning... having to learn all of those tools just to compile a
C++ program is perhaps biting off too much at once.)

--
James Kanze (GABI Software)             email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34
0
james.kanze (9769)
11/16/2007 11:01:30 AM
On 2007-11-16 05:18:08 -0500, Michael Bell <michael@beaverbell.co.uk> said:

> In message <o85%i.123$_X2.18@newsfe06.lga>
>           "Jim Langston" <tazmaster@rocketmail.com> wrote:
> 
>> "Michael Bell" <michael@beaverbell.co.uk> wrote in message
>> news:6d783c424f.michaelbell@michael.beaverbell.co.uk...
>>> In message <2007111510525016807-pete@versatilecodingcom>
>>> Pete Becker <pete@versatilecoding.com> wrote:
>>> 
>>>> On 2007-11-15 10:49:03 -0500, Michael Bell <michael@beaverbell.co.uk>
>>>> said:
>>> 
>>>>> 
>>>>> But I left caps lock on, and by mistake typed MESSAGE, and it didn't
>>>>> compile. I retyped message in lower case it did compile! I was
>>>>> astonished. I thought you could give variables any name you liked,
>>>>> capitalised or not.
>>>>> 
>>>>> What's the explanation? Is MESSAGE a reserved word?
>>>>> 
>>> 
>>>> No. It's probably a macro that's defined in "vcl.h".
>>> 
>>> I was unable to test this theory because it won't complile without
>>> #include <vcl.h> at the top - the error message gives a linker error
>>> and quotes vcl.h. And I can't trace A macro "MESSAGE" in "Borland
>>> Builder C++ 5 for Dummies" - but that's not proof.
>>> 
>>> It doesn't matter too much. I can still get on with the book. But I
>>> don't like it when something happens that I don't understand. But your
>>> suggestion allows me to lay that worry aside.
> 
>> So opne up hte file vcl.h and search for MESSAGE
> 
> I can't search vcl.h itself, or at least I don't know how to, but I
> have searched the help for it, and there is a macro called "MESSAGE"
> (UPPER CASE) so your suspicions are well founded and I know how I have
> tripped over an obstacle that I had no reason to suspect was there.
> All sorted then. Thank you everybody.
> 

A more general test would be to add

#undef MESSAGE

after the #include directive. But for simple programs like this one, 
you don't need vcl. And your code will compile without vcl. You have to 
find the compiler settings that get rid of whatever non-standard thing 
is getting in the way.

-- 
  Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The 
Standard C++ Library Extensions: a Tutorial and Reference 
(www.petebecker.com/tr1book)

0
pete2666 (1733)
11/16/2007 1:29:52 PM
Reply:

Similar Artilces:

""""""""""""""""""""""ADD ME""""""""""""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... We look forward to build a ve...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

Urgent Requirement in """""""""""""NEW YORK""""""""""""""""
Hello Partners, Please find the requirement below. Please send the updated resume along with rate and contact no. REQ#1: Title : Java Developer ( Rating Project) Duration : 6 months Rate : open Location : NY strong java, WebLogic 9.2, Web Services, Oracle REQ#2: Title : Java Developer Duration : 4 months Rate : open Location : NY Strong java, SQL REQ#3: Title : VB.Net Consultant Location : NY Duration : 4 months Rate : open Primarily looking at someone who has Excel, VB.net a...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

"If then; if then;" and "If then; if;"
I have a raw data set which is a hierarchical file: H 321 s. main st P Mary E 21 F P william m 23 M P Susan K 3 F H 324 S. Main St I use the folowing code to read the data to creat one observation per detail(P) record including hearder record(H): data test; infile 'C:\Documents and Settings\retain.txt'; retain Address; input type $1. @; if type='H' then input @3 Address $12.; if type='P' then input @3 Name $10. @13 Age 3. @16 Gender $1.; run; but the output is not what I want: 1 321 s. main H 2 321 s. main P Mary E 21 F 3 321 s...

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my $fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our $fz = 'VTX_Linkset'; ... } So the initial contents of the $fz declared with "my" is lost, because "our" creates a lexical alias for the global $fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

Urgent Requirement for """""""""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting ...

Urgent need """""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting Database/ETL requirements (Optional) ...

How to change "/" to "\"
Now, the output as below /a/b/c.txt b/c.txt x:/b/c.txt , Need to change x:\b\c.txt #!/bin/ksh # echo.ksh a=/a/b/c.txt echo $a echo ${a#/*/} y=`echo x:/${a#/*/} | tr -s '/' '\'` echo $y moon wrote: > Now, the output as below > > /a/b/c.txt > b/c.txt > x:/b/c.txt , Need to change x:\b\c.txt > > > #!/bin/ksh > # echo.ksh > a=/a/b/c.txt > echo $a > echo ${a#/*/} > y=`echo x:/${a#/*/} | tr -s '/' '\'` > echo $y > > One escape necessary: echo x:/${a#/*/} | tr -s '/' '\\' Two escapes necessar...

how to change "/" to "\"
iam new to shell scripting and i have plz can anyone help in changing the pattrern "/" to "\" using the sed command. olympie@gmail.com wrote: > iam new to shell scripting and i have plz can anyone help in changing > the pattrern "/" to "\" using the sed command. sed 's/\//\\/g' will replace all '/' with '\' srp -- http://saju.net.in Saju Pillai <saju.pillai@gmail.com> wrote: >> iam new to shell scripting and i have plz can anyone help in changing >> the pattrern "/" to "\" using ...