[Dev-C++] Lookup tables, with bsearch, lsearch, qsort etc.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2003-01-15 15:29:42
|
I'm trying to understand lookup tables and the bsearch, lsearch, qsort
functions. I'm trying to create a structure with an integer and a text
string, and I want to look up the number and get the text associated with
it. for example, at the moment I have
// BIG switch here
switch (PaperSize) // can be 1 - 41
{
case 1: ListBox = "Paper Type: Letter";
Listbox->AddString(ListBoxChoice);
break;
case 2: //... the same again
//...
case 41: // same again
I'm trying to replace this with a lookup table but I'm finding it difficult
- examples on the net about bsearch are not quite what I need.
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
|