Connecting Tech Pros Worldwide Help | Site Map

ERROR MESSAGES

  #1  
Old July 23rd, 2005, 12:31 AM
stanlo
Guest
 
Posts: n/a
Hllo to everyone, this is a folow up of my mathematical expression
assignment.i was tod to do one thing at a time , that i m doing and
have a better derstnding of the whole thing.someone asked me to use
standard libary ,to store my ror messeges instead o arrays. i have a
trial here.please is it a good one, i need your comments.


const char EnterExp = "Please give an expession and press the ENTER
key";

const char result= " The Answer is: ";

const char DivByZero= "WARNING!!!:No Division by Zero;Check answer.";

const char FloatPtNo = "WARNING!!!:No decimal points
allowed,discarded.";

  #2  
Old July 23rd, 2005, 12:31 AM
Mike Wahler
Guest
 
Posts: n/a

re: ERROR MESSAGES



"stanlo" <mungwest@yahoo.com> wrote in message
news:1105203759.025956.95820@c13g2000cwb.googlegro ups.com...[color=blue]
> Hllo to everyone, this is a folow up of my mathematical expression
> assignment.[/color]

I'm afraid nobody is going to be able to offer much help
if you don't give the *exact* description of your assignment.
[color=blue]
> i was tod to do one thing at a time , that i m doing and
> have a better derstnding of the whole thing.[/color]

But imo your understanding of C++ is still very lacking.
[color=blue]
>someone asked me to use
> standard libary ,to store my ror messeges instead o arrays. i have a
> trial here.please is it a good one, i need your comments.[/color]

We need a coherent explanation of your assignment.
[color=blue]
>
>
> const char EnterExp = "Please give an expession and press the ENTER
> key";[/color]

This is not valid. You're trying to store a pointer value
into a type 'char' object.
[color=blue]
>
> const char result= " The Answer is: ";[/color]

And again.
[color=blue]
>
> const char DivByZero= "WARNING!!!:No Division by Zero;Check answer.";[/color]

And again.
[color=blue]
>
> const char FloatPtNo = "WARNING!!!:No decimal points
> allowed,discarded.";[/color]

And again.

I think you need to go back and spend some serious time with
your textbook, and try to write some much simpler programs
before you're able to tackle this.



-Mike


  #3  
Old July 23rd, 2005, 12:31 AM
Morten Aune Lyrstad
Guest
 
Posts: n/a

re: ERROR MESSAGES


stanlo wrote:[color=blue]
> Hllo to everyone, this is a folow up of my mathematical expression
> assignment.i was tod to do one thing at a time , that i m doing and
> have a better derstnding of the whole thing.someone asked me to use
> standard libary ,to store my ror messeges instead o arrays. i have a
> trial here.please is it a good one, i need your comments.
>
>
> const char EnterExp = "Please give an expession and press the ENTER
> key";
>
> const char result= " The Answer is: ";
>
> const char DivByZero= "WARNING!!!:No Division by Zero;Check answer.";
>
> const char FloatPtNo = "WARNING!!!:No decimal points
> allowed,discarded.";
>[/color]
No, that won't work. You are making variable constants which can only
hold one character.

Use
const char *EnterExp = "Please ...";

Those who suggested you used standard libraries most likely wanted you
to use std::string, which is far, far easier to use than the "const
char*" type string. You can get it by inserting
#include <string>
at the top of your file.
  #4  
Old July 23rd, 2005, 12:31 AM
David Harmon
Guest
 
Posts: n/a

re: ERROR MESSAGES


On Sat, 08 Jan 2005 18:15:30 +0100 in comp.lang.c++, Morten Aune
Lyrstad <morten@wantsno.spam> wrote,[color=blue]
>No, that won't work. You are making variable constants which can only
>hold one character.
>
>Use
> const char *EnterExp = "Please ...";[/color]

No need for the gratuitous pointer. Prefer

const char EnterExp[] = "Please ...";

  #5  
Old July 23rd, 2005, 12:31 AM
Victor Bazarov
Guest
 
Posts: n/a

re: ERROR MESSAGES


"David Harmon" <source@netcom.com> wrote...[color=blue]
> On Sat, 08 Jan 2005 18:15:30 +0100 in comp.lang.c++, Morten Aune
> Lyrstad <morten@wantsno.spam> wrote,[color=green]
>>No, that won't work. You are making variable constants which can only
>>hold one character.
>>
>>Use
>> const char *EnterExp = "Please ...";[/color]
>
> No need for the gratuitous pointer. Prefer
>
> const char EnterExp[] = "Please ...";
>[/color]

Why? Why did you use the term "gratuitous"? No, I am not trying
to pick a fight. I really want to know. Perhaps you will include
that in your answer, but in case you don't, why prefer an array
over a pointer, if the pointer is never assigned to? Or is it only
to prevent assigning to it?

V


  #6  
Old July 23rd, 2005, 12:31 AM
David Harmon
Guest
 
Posts: n/a

re: ERROR MESSAGES


On Sat, 8 Jan 2005 15:28:33 -0500 in comp.lang.c++, "Victor Bazarov"
<v.Abazarov@comAcast.net> wrote,[color=blue][color=green][color=darkred]
>>>Use
>>> const char *EnterExp = "Please ...";[/color]
>>
>> No need for the gratuitous pointer. Prefer
>>
>> const char EnterExp[] = "Please ...";
>>[/color]
>
>Why? Why did you use the term "gratuitous"?[/color]

The pointer occupies an extra sizeof(char *) bytes of memory.
Gratuitous = not being used in any way that adds to the
functionality of the program. As you point out, the pointer is
never assigned to, so why do you need it?

The (char *) has external linkage and the pointer value is not
const, so I suspect that only a heroic optimizer could do anything
to avoid loading it whenever it is used.

On the other hand, the array location is a compile-time constant,
and ought to be accessible from any kind of code with no extra
overhead.

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Error Messages in Access hyperpau insights 1 January 16th, 2009 03:11 PM
suppress Javascript error messages in vb .net ZeeHseez@gmail.com answers 2 June 1st, 2007 05:05 PM
SQLServer 2000 JDBC /SQL Exception Error Messages - Meaning? Steve answers 5 June 30th, 2006 10:34 AM
How can error messages be displayed when using Command Buttons - Access 97 ? bjbounce2002@hotmail.com answers 1 November 13th, 2005 07:41 AM
Why are g++ error messages so daunting? Markus Dehmann answers 11 July 22nd, 2005 04:31 PM