• C

How do you open files using C?

okay...i am pretty new and was wondering if someone could show me how to open programs with C...and set timers to open the programs at specific times.  I am really new at this and please!!!! I am begging of someone to help me :)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

#include <stdio.h>
FILE *fopen (const char *filename, const char *type);
/* will open files */

/* depending on what you mean by open programs, */
#include <stdlib.h>
int system (const char *string);
/* may be what you want */
This is highly OS specific, the 'system()' call should work on all platforms. Waht OS do you target?
What ? Clarify
Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

<ozo, 1st to comment, I'm shocked!>

ofro, as much information as you can give will help everyone give you the best answer possible, as your question now stands, there's just too many things that can effect the answer.
What I mean is you'r reference to "and set timers to open the programs at specific times", can mean a lot of things; do you mean something like you want to use an application like 'Task Scheduler' to open the program that opens the files? Or do you mean the program that opens the files does it?
Do you want to open a program or open a file?

Open a file:

FILE *fp;

if ((fp = fopen("filename", "r")) == NULL) {
    return error;
} else {
   /* do what you need to do here with fp */

Open a program:

if (fp = popen("program_name") == NULL) {
    return error;
} else {
    /* if you need to send input or read output to the process
        do it here with fp */

These calls *will* work on all relevant platforms (solaris, win, hpux). You should check the documentation for specific details.
You should stay away from system in my personal opinion.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ofroAuthor Commented:
Yeah...this was definitley better than the other answers and actually helped me alot considering that my question absolutely gave no description of what I was trying to do.  Good job!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.