Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Table in DLL

Posted on 1997-05-04
2
Medium Priority
?
256 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

721 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