This language bar is your friend. Select your favorite languages!

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").

const util = require("util");
console.error(util.format("%d is negative", x));
console.error(x, "is negative");
with Ada.Text_IO;
use Ada.Text_IO;
Put_Line (Standard_Error, Integer'Image (X) & " is negative");
#include <stdio.h>
fprintf(stderr,"%d is negative\n",x);
(binding [*out* *err*]
  (println (str x " is negative")))
#include <iostream>
std::cerr << x << " is negative" << std::endl;
using namespace std;

int main(){
	int x = -2;
	cerr<<x<<" is negative"<<endl;
import System;
Console.Error.WriteLine($"{_x} is negative");
import std.stdio;
stderr.writeln(x, " is negative");
import "dart:io";
stderr.write("$x is negative");
IO.puts :stderr, "#{x} is negative"
io:format(standard_error, "~p is negative~n", [X]).
program write_to_stderr
   use iso_fortran_env, only : stderr=>ERROR_UNIT   
   implicit none
   integer :: x=-2
   write(stderr,'(i0," is negative")') x
end program write_to_stderr
import "os"
fmt.Fprintln(os.Stderr, x, "is negative")
import System.IO (hPutStrLn, stderr)
hPutStrLn stderr (show (x) ++ " is negative")
System.err.format("%d is negative\n",x);
System.err.println("$x is negative")
(format *error-output*
        "~a is negative"
io.stderr:write(string.format("%d is negative\n",x))
$stderr = fopen('php://stderr', 'w+');
fwrite($stderr, "{$x} is negative\n");
writeln(StdErr, Format('%d is negative',[-2]));
writeln(StdErr , x , ' is negative');
print STDERR "$x is negative";
import sys
print(x, "is negative", file=sys.stderr)
import sys
print >>sys.stderr, "%s is negative" % x
warn "#{x} is negative"
$stderr.puts "%d is negative" % x
eprintln!("{} is negative", x);
System.err.println(s"$x is negative")

Do you know the best way to do this in your language ?
New implementation...

Idiom created by