QQ wrote:
How to define a string?
Usually we can
#define MAX 30
However if I'd like to define a string const
can I?
#define S "Hello"
seems not working
Thanks
Just remember that the #define is a substitution
that takes place before the translation phase.
So, when using the #define, try getting the syntax
correct first:
/* First try with this syntax */
const char * S = "Hello";
/* Then move it to a #define: */
#define S (const char *)("Hello")
{Although literal strings are constants.}
--
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