strings or character arrays

This is a discussion on strings or character arrays within the C++ Programming forums, part of the General Programming Boards category; which are better to use? strings or character arrays. My program involves setting locations that must be described using words. ...

  1. #1
    Shadow12345
    Guest

    strings or character arrays

    which are better to use? strings or character arrays.

    My program involves setting locations that must be described using words.
    Code:
    sensor *X = new sensor("On", "Near the back porch window");
    right now i am using character arrays, but i am thinking of just using string, any opinions?

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    strings are easier to manage. You don't have to worry about buffer overflows or memory management with them, and I highly doubt that string manipulation is going to be a bottleneck in your code, so I'd say, go for the string class.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Shadow12345
    Guest
    yeah that's what I was thinking, i just wanted someone else to confirm this, thanks silent.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. copying strings to heap character arrays
    By SkyRaign in forum C++ Programming
    Replies: 4
    Last Post: 11-26-2006, 01:08 PM
  2. Just a quick question about character arrays
    By Welshy in forum C Programming
    Replies: 3
    Last Post: 04-03-2006, 07:20 AM
  3. Comparing Character Arrays
    By LostNotFound in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2003, 11:42 AM
  4. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM
  5. Structures Arrays and Char Strings
    By Crocksmyworld in forum C Programming
    Replies: 5
    Last Post: 01-19-2002, 10:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21