To launch and run another program from within your code, use the system() function. When your code must examine or save that program’s output, use the popen() function.
Continue reading
Author Archives: dgookin
Execute and Leave
The system() function allows you to run one program from within another. If it’s your desire to launch another program and have your program quit, you can immediately follow system() with an exit() function. Or you can go out of your way and use the oddball execl() function.
Continue reading
Let’s Go Bowling – An Entire Game – Solution
To make the conversion between simulating a single frame of bowling and an entire game isn’t that simple, which is mostly due to calculating the dreaded 10th Frame.
Continue reading
The Joys of Iteration
Suppose that you’re testing code and need to run a program six times in a row. You could keep repeating the program, running it multiple times, but why not write a utility that does the same thing? That would be a good and practical way to put the system() function to work.
Continue reading
Let’s Go Bowling – An Entire Game!
In last month’s Exercise, the assignment was to craft a single frame in a game of bowling. This time, you need to stitch together 10 frames to simulate bowling an entire game.
Continue reading
Hello, System
One thing that continues to puzzle me about learning the C language is how frequently beginners use the system() function. Is it a crutch? Is it a necessity? What’s the allure of this function that makes it show up in beginner code?
Continue reading
Before You Say Goodbye . . .
The standard C library contains a lot of interesting and unusual routines. Some can really put the fun into function. One of them I’ve rarely used, but which can be extremely handy, is atexit().
Continue reading
Build Your Own strcasestr() Function
I was a bit surprised the other day. I’d written code on my Macintosh and tried to run it on the PC. Because I usually write generic stuff, I figured that the code would compile and run on both systems. But it didn’t compile.
Continue reading
Parsing the Command Line IV
Command line options often sport their own options or settings. For example, tab width might be set by specifying the tabwidth option followed by a value. No hard and fast rules exist for how such an option is set, but I’ve seen it happen in one of three ways:
Continue reading
Let’s Go Bowling – Solution
You may find my solution for this month’s Exercise to be more complex than necessary, but there’s a method to my madness.
Continue reading