Thread: Strings for Non-char Data Types?

  1. #1
    Registered User
    Join Date
    Aug 2005

    Strings for Non-char Data Types?

    Is it possible (or practical) to use strings to hold data types other than text strings and characters?

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    A string holding text strings is definitely not useful.

    A basic_string of wchar_t is very useful and even has its own typedef wstring (just as string is a typedef for a basic_string of char).

    If you want other types, which is certainly possible and can be useful for some character encodings, you need to specialize the char_traits template on this type.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Toronto, ON
    You mean like std::vector<unsigned char> ?
    That should be able to store any kind of bytes from 0x00 to 0xFF.

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    It's possible, but not practical.
    int, char, BOOL, HANDLE, are all just different size byte groups; For example, char[4] can hold the exact same data as int.
    I just want to use my computer in a productive manner, not learn how to use it. Elysia
    A year spent in artificial intelligence is enough to make one believe in God. Alan Jay Perlis

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  3. Need help fixing bugs in data parsing program
    By daluu in forum C Programming
    Replies: 8
    Last Post: 03-27-2003, 06:02 PM
  4. Strings are V important...
    By NANO in forum C++ Programming
    Replies: 15
    Last Post: 04-14-2002, 11:57 AM