ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 ) > .
Why do you want to call the same entire executable for the C executable running.
If the executable is some other program other than what you are forking from, then you can use the system function call:
Code:
Function: int system (const char *command)
You can code to call the same executable by nesting or recursive use of main() function call. main() can call itself. Using main() to call main() is like running the same executable again !!!
i wanna to call specific function from the executeable file, is there anyway i can do it ?
I guess you want to use functions spread across several C source files. For this you need to link together all the object files and create a single executable using the make command. From this executable you can call all executable functions defined in your source codes.
You can read any standard tutorial about creating Makefile to solve your problem
when mainfile.c compile to executable,
other source C can call its themself <function in define> ?
for accessing the functions of mainfile.c from other executables you need to link its object file. For this you just need the object file of mainfile.c
Code:
gcc -c mainfile.c
Then link all the other object files of different source with mainfile.o using Makefile by providing suitable dependencies.
Your code is trying to do the work that a linker normally does. The usual way to do what you are suggesting is to create separate source files, of which only one has a function 'main()'. The other source files have only public functions, and are compiled to object modules, and then linked with the object module containing 'main()'.
It is possible to contrive a scheme where you could load and execute a fully linked standalone object module, and have it dispatch to various functions that are contained within it, but this would be unusual, and very convoluted. I feel certain that this is not what you intended.
--- rod.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.