I have done programs that print themselves on execution,but is it possible for a c program to execute itself or another c program whose path is specified??

Recommended Answers

All 3 Replies

Member Avatar for iamthwee

I have done programs that print themselves on execution,but is it possible for a c program to execute itself or another c program whose path is specified??

You mean executing another program from within a program?

Yes. Want to know how?

It's operating system specific, but one general option is to use the 'system' procedure. Or, if you're using a Unixy operating system and want more control over how things are done, look at execve and its friends ('fork' followed by 'execv' will start a new process. You'd have to understand how these work, which you can do by, um, reading documentation). (If you're looking at a Windows operating system, you can find documentation on its API online somewhere too.)

thanks.. the system fuction sugeested does the job I needed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.