-1

I have a Structure :-

Test.h

typedef struct employees
{
    char* name[5];
    int empi_id;
};

Test.cpp I created a function where I need store the values within these structure.

int Disp()
{
    employees e[5];
    e[0].empi_id=10;
    e[1].empi_id=100;
    e[2].empi_id=500;
    e[3].empi_id=1000;
    e[4].empi_id=5000;
    return 0;
}

TestDll.cpp Console Application:

void main()
{
    LoadLibrary(("TestDll.dll"));

    int obj = Disp();
}

I need to return these array of structure to my Console Application.I want to display the assigned values in my Console Application directly.How Should I return it?Can I send these array of structure as a function parameter then how should I do it.Since I need to send an array of 5. Checking out the below link did gave me an idea of assigning the values to the structure but I cant display the values in my Console App. return an array of structs or an array of struct pointers?

1
  • Anything to do with C++/CLI? Commented May 25, 2015 at 7:28

1 Answer 1

1

Change function signature in to

int Disp(employees *) ;

it' OK. What is not ok is how you link your DLL. You can either loat it at startup (it happens behind the scenes) or with LoadLibray, but this requires a GetProcAddress too. First way it's easier. It allows you to load a DLL as if it were a library.

Sign up to request clarification or add additional context in comments.

6 Comments

@ marom : so if i use the structure as function parameter ,can i display all the values stored at different index ie for(int i =0;i<5;i++){ e[i].empi_id int::Parse(Console::ReadLine())} ?????
:I have a problem in accessing the name ?? @marom
accessing th variable "name" @marom
Well the dll must know the definition of struct employees. But declaration of name looks wrong, I would expect char name[], not char *name[] that declares an array of pointers to char.
I require five employees names ,Since char array stores single character I used them .I need to pass this structure to C# .If I just use char name[] ,can I pass this structure to C#??? @marom
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.