Logo

Programming-Idioms

  • C++
  • Haskell

Idiom #59 Write to standard error stream

Print the message "x is negative" to standard error (stderr), with integer x value substitution (e.g. "-2 is negative").

import System.IO (hPutStrLn, stderr)
hPutStrLn stderr (show (x) ++ " is negative")
#include<iostream>
int main(){
	int x = -2;
	std::cerr << x <<" is negative\n";
}
#include <iostream>
std::cerr << x << " is negative\n";
with Ada.Text_IO;
use Ada.Text_IO;
Put_Line (Standard_Error, Integer'Image (X) & " is negative");

New implementation...
< >
programming-idioms.org