Thread: Strings And Arrays

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    32

    Angry Strings And Arrays

    HELP. I am very new to c++ and am not quite understanding strings and arrays can someone help me out plzzzzzz....

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    27
    First tell us what it is you don't understand, then someone might be able to help you. If you don't know what you don't understand, go read some more tutorials/books.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    An array is a sequence of items with the same type, such as int or char. A string is a sequence of chars that always end with the '\0' character. A C string is an array of those chars where the last element in the array is the nul. The C++ string class is god's gift to programmers, C strings have a set length and it takes some tweaking to change the length if you want to, but the C++ String class can dynamically change it's length with fair ease

    Array:
    char a[] = {'a','b','c','d'};

    C String:
    char a[] = {'a','b','c','d','\0'};
    or the short form which is the same
    char a[] = "abcd";

    C++ String:
    string a = "abcd";

    I can explain more with a better idea of what you don't understand.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help understanding arrays of strings!
    By smoking81 in forum C Programming
    Replies: 18
    Last Post: 02-23-2008, 04:24 AM
  2. Strings and Substrings using arrays
    By dcwang3 in forum C Programming
    Replies: 12
    Last Post: 02-18-2008, 07:28 AM
  3. arrays of strings
    By mbooka in forum C Programming
    Replies: 2
    Last Post: 02-19-2006, 07:55 PM
  4. strings or arrays of characters?
    By Callith in forum C++ Programming
    Replies: 13
    Last Post: 12-26-2004, 11:28 AM
  5. strings or character arrays
    By Shadow12345 in forum C++ Programming
    Replies: 2
    Last Post: 07-21-2002, 10:55 AM