ERROR MESSAGES

S

stanlo

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.";
 
M

Mike Wahler

stanlo said:
Hllo to everyone, this is a folow up of my mathematical expression
assignment.

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

But imo your understanding of C++ is still very lacking.
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.

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

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

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

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

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
 
M

Morten Aune Lyrstad

stanlo said:
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.";
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.
 
D

David Harmon

On Sat, 08 Jan 2005 18:15:30 +0100 in comp.lang.c++, Morten Aune
Lyrstad said:
No, that won't work. You are making variable constants which can only
hold one character.

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

No need for the gratuitous pointer. Prefer

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

Victor Bazarov

David Harmon said:
On Sat, 08 Jan 2005 18:15:30 +0100 in comp.lang.c++, Morten Aune
Lyrstad said:
No, that won't work. You are making variable constants which can only
hold one character.

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

No need for the gratuitous pointer. Prefer

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

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
 
D

David Harmon

On Sat, 8 Jan 2005 15:28:33 -0500 in comp.lang.c++, "Victor Bazarov"
Use
const char *EnterExp = "Please ...";

No need for the gratuitous pointer. Prefer

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

Why? Why did you use the term "gratuitous"?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,634
Latest member
RonnyBoelk

Latest Threads

Top