# EPANET: Embedded Engine Example

Embedded Engine Example

This example shows how simple it is for the Toolkit to provide a network analysis engine for other applications. There are three steps that the application would need to take:

1. Have the application write network data to an EPANET-formatted input file.
2. Create a project and call EN_runproject, supplying the name of the EPANET input file, the name of a Report file where status and error messages are written, and the name of a binary Output file which will contain analysis results.
3. Have the application access the output file to display desired analysis results (see Output File).

Here is an example where a callback function `writeConsole` is provided to write EPANET's progress messages to the console:

#include "epanet2_2.h"
void writeConsole(char *s)
{
fprintf(stdout, "\n%s", s);
}
int runEpanet(char* inpFile, char* rptFile, char* outFile)
{
int errcode;
EN_project ph;
EN_createproject(&pH);
errcode = EN_runproject(ph, inpFile, rptFile, outFile, &writeConsole);
EN_deleteproject(ph);
return errcode;
}