473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

string table in c?

hello.

My question has to do with string tables. I want to be able to extract
the string associated with the ID. Can I do this in c? If I were
using C++/MFC, I could just simply use...

CString str;
str.LoadString(ID_NUM);

However, I can't use MFC in c. Can someone help?

Thanks!

Feb 6 '06 #1
2 9305
sh********@gmail.com wrote:

hello.

My question has to do with string tables. I want to be able to extract
the string associated with the ID. Can I do this in c? If I were
using C++/MFC, I could just simply use...

CString str;
str.LoadString(ID_NUM);

However, I can't use MFC in c. Can someone help?


Well, one method would be to define a struct which contains the ID and a
pointer to the string, and initialize an array of it:

typedef struct
{
int id;
char *str;
}
STRING_TABLE;

STRING_TABLE StringTable[] =
{
ID_FOO, "foo",
ID_BAR, "bar",
0,NULL
};

Then write your MyLoadString() function to search StringTable[] for the
specified ID. How you do this is up to you. If the table is going to
be large, you may want to require the table be sorted on ".id", and
then do a binary search to find the entry.

OT:

However, given that the MFC CString::LoadString() method in C++ actually
loads the string from disk, the above may not be what you _really_ want.
You may want the Windows LoadString() API call, for which you will need
to ask a Windows-specific newsgroup if you need further help.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Feb 6 '06 #2
sh********@gmail.com wrote:
hello.

My question has to do with string tables. I want to be able to extract
the string associated with the ID. Can I do this in c? If I were
using C++/MFC, I could just simply use...

CString str;
str.LoadString(ID_NUM);

However, I can't use MFC in c. Can someone help?


This is highly Windows specific so you should ask in a Windows group.
There are plenty to choose from. Here we only deal with standard C and
not the specifics of all the many operating systems and libraries
available to use with it.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Feb 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: James Stroud | last post by:
Hello, I am looking for a nice way to take only those charachters from a string that are in another string and make a new string: >>> astr = "Bob Carol Ted Alice" >>> letters = "adB" >>>...
28
by: David Rubin | last post by:
I looked on google for an answer, but I didn't find anything short of using boost which sufficiently answers my question: what is a good way of doing string tokenization (note: I cannot use boost)....
10
by: M Bourgon | last post by:
I'm trying to figure out how to find the last whitespace character in a varchar string. To complicate things, it's not just spaces that I'm looking for, but certain ascii characters (otherwise,...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
2
by: adambossy | last post by:
I have a nasty situation in SQL Server 7.0. I have a table, in which one column contains a string-delimited list of IDs pointing to another table, called "Ratings" (Ratings is small, containing...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
7
by: Matik | last post by:
Hi to everyone, My problem is, that I'm not so quite sure, which way should I go. The user is inputing by second part application a long string (let's say 128 characters), which are separated...
1
by: kellysgirl | last post by:
Now what you are going to see posted here is both the set of instructions I was given..and the code I have written. The instructions I was given are as follows In this case, you will create...
5
by: kanley | last post by:
I have a main table with a text description field. In this field, its populated with a string of data. I need to identify from this string of data the name of the vendor using some keywords. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.