Solved

Table in DLL

Posted on 1997-05-04
2
249 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
Comment Utility
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
Comment Utility
Fine answer! Thanks...
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

728 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

15 Experts available now in Live!

Get 1:1 Help Now