Solved

Table in DLL

Posted on 1997-05-04
2
250 Views
Last Modified: 2010-04-15
have a C module containing several functions. In each of the function
I have a Table of 256 entries based on a struct...


        struct  MYTABLE
        {
                unsigned char text[10];
                unsigned char outtext[10];
        };          

        //unsigned int y;
    //static unsigned char chr;    
    //unsigned int chr;
        // 255 enheter av strukten hvor hver innholder karakterstrengen    
struct MYTABLE Table[256];
        strcpy(Table[9].text,"&newlin;");    
        strcpy(Table[9].outtext,"\x09");    


I use the Table for converting strings, checking against the Table.text
writing out the contents of the Table.outtext.

This Table is initalized every time a string is passed to it. Is it
possible to locate the Table outside the function, making it possible so
that the table is only initialized once, when the DLL is loaded??

Is it a better/faster way to initialize the elements in the Table than
using strcpy?


Help
0
Comment
Question by:geira
2 Comments
 
LVL 1

Accepted Solution

by:
prc earned 0 total points
ID: 1250244
Yes to both - use static initialisers like this:

struct MYTABLE table[256] =
{
  { "&",         "&" },
  { "&lt;",          "<" },
  /* ... etc ... */
  { "&last-entry;",  "\xff" }
};

That's your lot for a measly 5 points! ;-)

0
 

Author Comment

by:geira
ID: 1250245
Fine answer! Thanks...
0

Featured Post

Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to organize data in excel ? 2 111
How to create frequencies of a variable from SAS dataset? 10 120
Passing command line arguments in C 10 85
Line meaning 9 81
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now