Why /0 can't terminate string? please help

Discussion in 'C Programming' started by Jackyms0083, Sep 30, 2006.

  1. Jackyms0083

    Jackyms0083

    Joined:
    Sep 30, 2006
    Messages:
    1
    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!
    Jackyms0083, Sep 30, 2006
    #1
    1. Advertising

  2. Jackyms0083

    Mash_online

    Joined:
    Nov 14, 2006
    Messages:
    1
    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
    Mash_online, Nov 14, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. feng
    Replies:
    1
    Views:
    1,491
    =?Utf-8?B?U3VyZXNo?=
    Feb 29, 2004
  2. ad
    Replies:
    3
    Views:
    4,151
    Mark Rae
    Aug 13, 2005
  3. KK
    Replies:
    2
    Views:
    526
    Big Brian
    Oct 14, 2003
  4. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    863
    Mark Rae
    Dec 21, 2006
  5. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,762
    Smokey Grindel
    Dec 2, 2006
Loading...

Share This Page