Re: [Dev-C++] Lookup tables, with bsearch, lsearch, qsort etc.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ho...> - 2003-01-16 13:35:09
|
-------Original Message-------=0D
=0D
From: Daniel Glenfield=0D
Date: Thursday, 16 January 2003 11:09:47 AM=0D
To: pw...@ia...=0D
Cc: dev...@li...=0D
Subject: Re: [Dev-C++] Lookup tables, with bsearch, lsearch, qsort etc.=0D
=0D
Thanks I'll do some research.=0D
Can you tell me how to put these values in to a struct?=0D
=0D
1, "Letter"=0D
2, "Letter(small)"=0D
3, "Tabloid"=0D
=0D
etc. I'm having trouble with this.=0D
=0D
// I asssume C=0D
=0D
=3D=3D> #include <string.h>=0D
=0D
=0D
struct PAPER=0D
{=0D
int Num;=0D
char* PaperStrings[42][1];=0D
=0D
=3D=3D>The 1 thing is reduntant!=0D
=0D
=3D=3D> char *PaperStrings[42];=0D
=0D
=0D
} PaperTypes, *PaperStruct =3D &PaperTypes;=0D
=0D
PaperTypes.Num =3D 1;=0D
=0D
PaperTypes.PaperStrings[42][1] =3D "Letter";=0D
=0D
=0D
=3D=3D> strncpy(PaperTypes.PaperStrings, "Letter", 42);=0D
=0D
=0D
PaperStruct->PaperStrings[40][1] =3D "Letter(small)";=0D
=0D
=3D=3D> /* ... */=0D
=0D
As you can see this is very wrong. I feel an idiot, but all the examples =
of =0D
structs I have seen do not use arrays or do anything like this, so I don'=
t =0D
know how to do it!=0D
=0D
=0D
=0D
=3D=3D> I also suggest "The C Programming Language" 2nd Edition by Brian
Kernighan - Dennis Ritchie (the creator of C).=0D
=0D
=0D
Ioannis Vranos=0D
=0D
* Programming pages: http://www.noicys.freeurl.com=0D
* Alternative URL: http://run.to/noicys=20 |