It's UWAweek 48


This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

Displaying selected article
Showing 1 of 919 articles.
Currently 6 other people reading this forum.

 UWA week 34 (2nd semester, week 5) ↓
SVG not supported

Login to reply


The project doesn't require you to print out any explanation of how your project is working - in fact only the last line of output is considered during marking. However, you'll invariably want to print some 'debug' output while developing your project and, at times, may simply wish to "turn it all off" when there's too much of it. In today's Workshop-5 I quickly showed a technique that I use to turn debug printing on and off, without having to edit and re-compile code, or without adding new command-line arguments. The technique involves setting an environment-variable before running your project if you want debug output, or leaving it unset to omit debug printing. Near the top of your source-code, define a global variable:
#include <stdbool.h>
#include <stdlib.h>

bool debug = false;
Then, in main() set the Boolean variable if a specific environment-variable is set:
    debug = getenv("DEBUG");
In any function requiring debug printing, you should now add:
    if(debug) {
        printf("here we are!\n");
Finally, when running your project from the shell, set the environment-variable with:
    prompt>  DEBUG=y ./estimatecron aug crontab-file estimates-file
or omit the DEBUG=y if you don't want to see any debug printing. Good luck,

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy