C++/Visual C++ 6: Calling a function in a C program.
Let me put it more clearly.
I am writing a VC++6 MFC application. I want to integrate a third-party C program to create a Message Digest of Clipboard data. I am new to VC++. I somehow managed to obtain the Clipboard data in my VC++ function. Now I want to transfer this data to the C HASH program which I added to my project. Now here I am experiencing problems.
(1) The first problem is that the clipboard data can be of any size. When I transfer this to say function, HASH() of the C program, how to define the data type. Someone suggested me to use HASH(void *data, size_t dataLen).
(2) The second problem is that the C program contains a MAIN function, as it should be. So I need to pass the Clipboard data as an argument to the Main function of this C program.
In my VC++ project the main file RP.CPP contains functions which activate when a menu option is clicked. From these functions, i.e., from this RP.CPP I need to call the Main function of the C program with Clipboard data as an argument.
I have added a C program in my VC++ project and want to call its
functions when an option is clicked from the menu.
Do I need to create a Class for all the functions in the C program?
If a Class needs to be created, then where to create the Class and
what will be the base Class?
Rohit , Thank you for your question.
Since C does not include classes, it would make no sense to declare C functions as class members.
C functions can be called from C++ programs. Declare them in C++ source files as follows:
1. You cannot redefine a function argument list as you have indicated. You must supply the called function with the data in whatever way the called function expects it. The HASH function is declared in the Include file that comes with your library.
2. You cannot combine a Windows program with a C program containing a "main" function. Perhaps you need to run the C program as a separate process. I cannot advise you on this, as it depends on the library.
I suggest you read the instructions on using the library carefully, as well as studying the programming examples that come with it.
If you have further questions, please do not hesitate to ask.