Solved

Table in DLL

Posted on 1997-05-04
2
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and reading files 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.

738 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