Thread: Initializing Strings

  1. #1

    Initializing Strings

    Hey guys:

    I just had a simple question... How do you initialize strings in C++ to empty? I thought you could say string=""; and that would do it...but it obviously doesnt work. I would appreciate any help i could get.


  2. #2
    char string[10];
    string[0] = '\0';

  3. #3
    Registered User
    Join Date
    Apr 2002
    string My_Name="\0";
    "The most common form of insanity is a combination of disordered passions and disordered intellect with gradations and variations almost infinite."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. initializing 2d strings
    By Fox101 in forum C Programming
    Replies: 6
    Last Post: 02-05-2008, 10:16 AM
  2. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  3. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  4. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  5. Initializing strings
    By The_Nymph in forum C Programming
    Replies: 1
    Last Post: 04-30-2002, 01:01 PM