# set_outputstream, set_outputfile

Defines the output when lp_solve has something to report.

void set_outputstream(lprec *lp, FILE *stream);

unsigned char set_outputfile(lprec *lp, char *filename);

Return Value

set_outputstream has no return value.

set_outputfile returns TRUE (1) if the file could be opened, else FALSE (0).

Parameters

lp

Pointer to previously created lp model. See return value of make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI

stream

The stream to print the results to. If NULL, then output is stdout again.

filename

The file to print the results to. If NULL, then output is stdout again. If "", then output is ignored. It doesn't go to the console or to a file then. This is usefull in combination with put_logfunc to redirect output to somewhere completely different.

Remarks

The set_outputstream, set_outputfile functions define the output when lp_solve has something to report.
This is done at the same time as something is reported via put_logfunc. The default reporting output is screen (stdout). If set_outputstream is called to change output to another stream, then be aware that the stream is not closed automatically when delete_lp is called. Output must be set again to stdout (or NULL) to close this handle or the handle must be closed by the application via a call to fclose afterwards. This allows the application to still print to the stream even after the lp structure is cleaned up. If set_outputfile is called to change output to the specified file, then the file is automatically closed when delete_lp is called. Note that this was not the case in previous versions of lp_solve. If filename is "", then output is ignored. It doesn't go to the console or to a file then. This is usefull in combination with put_logfunc to redirect output to somewhere completely different.

Example

    #include <stdio.h>
    #include <stdlib.h>
    #include "lp_lib.h"

    int main(void)
    {
      lprec *lp;

      /* Create a new LP model */
      lp = make_lp(0, 0);
      if(lp == NULL) {
        fprintf(stderr, "Unable to create new LP model\n");
        return(1);
      }

      set_outputfile(lp, "log.txt");

      /*
      .
      .
      .
      */

      delete_lp(lp);

      return(0);
    }

lp_solve API reference

See Also delete_lp, free_lp, make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, put_logfunc, print_lp, print_objective, print_solution, print_constraints, print_duals, print_scales, print_tableau, print_str, print_debugdump, write_lp, write_LP, write_mps, write_freemps, write_MPS, write_freeMPS, write_basis