Call a C programming executable inside a C program

hi guys
i have only basic knowledge of C so guys plz help me .....

is C language support call the C executable inside the C ??

example contect mainA.c have a many function define in the struct,when i compile mainA and make a executable the name is ( A ),can i use executable C inside the C <my C program call the executable ( A ) > .

Thankss all ..

Hi,
You can call any other program in the operating system with, for example, system(), and it can call/run itself (ie another instance of itself). But what is it that You want to do? Pass values between them?

/Lakris

sory guys , i don't understand ..

the executable C have a many function , when i use the system(" ") then function name it actually call the exe file to run

what i want is ,
i wanna to call specific function from the executeable file, is there anyway i can do it ?

---------- Post updated at 08:27 AM ---------- Previous update was at 01:49 AM ----------

hai, guys...

the example content mainfile.c :

struct {
    char namefunction[40] ;
    int (*f)(int argc, char *argv[]) ;
}manyfunction[2] =
{
      {"func1",func1}
      {"func2",func2}
} 

int main (int argc, char *argv[]) {
 /* the code can access to struct match something function from request */

}

when mainfile.c compile to executable,
other source C can call its themself <function in define> ?

can i make a differences executable ?

Thankss..

You can't just call a function from an executable. If you want to graba function from a file as a function pointer and execute it, you have to do so from a shared library with the dlopen() series of calls. To compile a shared library instead of an executable file, add the -shared flag (and, on some architectures, -fPIC). See man dlopen.

Hi again. Your description is still a bit unclear.

You create the two programs Yourself?

If You intend to keep the programs separate maybe You should consider using program arguments, so You can control what function will be called? Or even "call itself" but with an argument to make it run a specific function. You can do that If You want it to run in its own process, instead of calling the function directly from the same process.

/Lakris

Hi!

Look at this document, it should answer many of your questions.
Program Library HOWTO

HTH,
Lo�c