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, 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.

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 this function 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.

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");
  
  /*
  .
  .
  .
  */
  
  set_outputfile(lp, NULL); /* closes the file. Don't forget this or file stays open ... */
  
  delete_lp(lp);

  return(0);
}

lp_solve API reference

See Also delete_lp, free_lp, make_lp, read_lp, read_LP, read_lpt, read_LPT, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, print_lp, print_objective, print_solution, print_constraints, print_duals, print_scales, print_tableau, print_str, print_debugdump