Computing.Net > Forums > Programming > Array of Strings

Array of Strings

Reply to Message Icon

Original Message
Name: igor12
Date: April 4, 2005 at 17:06:49 Pacific
Subject: Array of Strings
OS: WinXP
CPU/Ram: 1600/256
Comment:

I was wondering how I could make a 2 dimensional array of strings where the values are read from an input file. The input file would be called something like "input.dat" and it would contain data like this:
banco bank
regalo present
camiseta shirt
...

and the words would need to be written to a 2D array of strings, like this:
list[][] = { "banco", "regalo", "camiseta"
"bank", "present", "shirt"};

and from an input file of undetermined size. This is for a dictionary.

Thanks,

Igor


Report Offensive Message For Removal


Response Number 1
Name: Chi Happens
Date: April 5, 2005 at 09:28:49 Pacific
Subject: Array of Strings
Reply: (edit)

I am assuming this is c++? if so, I suggest using a class that holds the pair in a linked list or queue.

Hope this helps,
Chi

They mostly come at night...mostly


Report Offensive Follow Up For Removal

Response Number 2
Name: InfiniteRecursion
Date: April 5, 2005 at 12:27:09 Pacific
Subject: Array of Strings
Reply: (edit)

You could also use a map from the standard template library (STL).

...
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
...

map<const char*, int, ltstr> translator;
translator["bank"] = "banco";

...

etc.


Report Offensive Follow Up For Removal

Response Number 3
Name: wizard-fred
Date: April 5, 2005 at 13:20:29 Pacific
Subject: Array of Strings
Reply: (edit)

If your dictionary gets too big you will have to be able to search from your disk drive.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Array of Strings

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge