Why /0 can't terminate string? please help

Joined
Sep 30, 2006
Messages
1
Reaction score
0
Why /0 can't terminate string?
i know /0 can terminate the cstring, but how come it can't stop the string (class) in c++. I hear someone said because the c++string is a class and one of its member store the length of the array, so it won't scan its length when we run it again. we only change one of its variable.
is this true?? please show me a simple program to terminate the string(if possible).
Thx!
 
Joined
Nov 14, 2006
Messages
1
Reaction score
0
Hey pal

Try using \0 at the end of running characters (The key you use "/" is invalid)

check this out:
char * name;
name=new char(20);
name={"Madhur Shankar"};
cout<<"The Name Is "<<name<<"\n";

name[6]='\0';//I am Inserting a Null
cout<<"My Name Is"<<name<<"\n";

o/p may be:
The Name Is Madhur Shankar
The Name Is Madhur
 

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,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top