Data types to read and hold a "dictionary"

This is a discussion on Data types to read and hold a "dictionary" within the C++ Programming forums, part of the General Programming Boards category; What data types do you suggest to use for a dictionary? I've tried vectors of structures that contain two char ...

  1. #1
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318

    Data types to read and hold a "dictionary"

    What data types do you suggest to use for a dictionary?

    I've tried vectors of structures that contain two char arrays, but it doesn't seem to be a very good solution.

    What is the best way to read in dictionary files?

    I mean when you have a file that contains the word in one language, then some strange character in the middle and then the word in the second language and a newline, how would be the best way to read it in? I've tried reading it in by reading the whole thing with ReadFile() (Win32 API) and then going it through by checking all chars and storing them somewhere.
    It could also be done by reading some certain amount of chars (maybe 256) when I run out of them in my loop.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    I think I would use a
    std::map< std::string, std::string > dict;

    Then read the file such that
    std::string a="hello";
    std::string b="bonjour";

    Then finally
    dict[a] = b;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Looks simple
    "The Internet treats censorship as damage and routes around it." - John Gilmore

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need help as soon as possible.
    By hyrule in forum C++ Programming
    Replies: 7
    Last Post: 11-09-2005, 04:49 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. read data in files
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 07-18-2002, 11:45 AM
  4. Replies: 1
    Last Post: 03-03-2002, 03:55 PM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM

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