index | submit | rank | book

errxit – Error exit code

Write a program that reads a single integer from standard input. If the integer is negative, the program should exit with an error exit code (different than zero). If the integer is zero or positive, the program should exit with a success exit code (zero).

$ ./errxit && echo 'Ok'
$ ./errxit && echo 'Ok'



You can check the exit code from the command line by issuing the echo $? command or alternatively by running your program followed by && echo 'zero exit code' which is executed when the program returns 0.

try first: erro hello-cmd

try next: bytes2bits bits2bytes

index | submit | rank | book

Copyright © 2020-2023 Rudy Matela
All rights reserved