Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Why /0 can't terminate string? please help

Reply
Thread Tools

Why /0 can't terminate string? please help

 
 
Jackyms0083 Jackyms0083 is offline
Junior Member
Join Date: Sep 2006
Posts: 1
 
      09-30-2006
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!
 
Reply With Quote
 
 
 
 
Mash_online Mash_online is offline
Junior Member
Join Date: Nov 2006
Posts: 1
 
      11-14-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
subprocess terminate help Ernesto Python 7 11-16-2005 11:36 PM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments