From 7144d80e4f6e90bf82986c48492e3cf0a8072dfa Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 5 Feb 2017 11:07:05 +0100 Subject: Better error checking (avoid a div-by-0) --- histogram.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/histogram.cpp b/histogram.cpp index a12cd75..2a275e7 100644 --- a/histogram.cpp +++ b/histogram.cpp @@ -68,7 +68,13 @@ int main(int argc,char **argv){ } if(nbins<1){ - cerr<<"Invalid number of bins '"<maxtally)maxtally=tally; + if(maxtally==0){ + cerr<<"histogram: No data in range"<