Setting a String to NULL in C++?

P

perseus

I have a string, say GLOBAL, that I use a lot
in a CPP-program. From time to time this string needs to
be set to the NULL-string, i.e., empty itself of its content.
How do we do it?
Thanks!

Perseus
 
V

Victor Bazarov

perseus said:
I have a string, say GLOBAL, that I use a lot
in a CPP-program. From time to time this string needs to
be set to the NULL-string, i.e., empty itself of its content.
How do we do it?

To empty a string call the 'clear' member function. There
is no 'setting to NULL' because it's not a pointer.

Victor
 
P

perseus

To empty a string call the 'clear' member function. There
is no 'setting to NULL' because it's not a pointer.

Victor

Victor,

Can I call this function in BC5 with Windows XP?
What .h file is needed here?
An example would be just great!
Thanks!

perseus
 
C

Chris Johnson

perseus said:
Can I call this function in BC5 with Windows XP?

Any C++ compliant compiler can do this regardless
of platform.
What .h file is needed here?

#include said:
An example would be just great!

string foo("Bar need's a good C++ book");

// examines include dir's more often

foo.clear();

Respectfully,
Chris Johnson
 
A

Ales DOLECEK

It should, but since your compiler is obviously broken, how about the
obvious

foo = "";

john

It has nothing to do with compiler. It is unimlemented in STL you are
using.

BTW: I use STL from SGI on linux and have same "problem" which I solve
in same way as John. :)

Ales
 

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

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top