diff options
-rw-r--r-- | histogram.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
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 '"<<nbins<<"'"<<endl; + cerr<<"histogram: Invalid number of bins '"<<nbins<<"'"<<endl; + usage(); + return 1; + } + + if(havebounds&&high<=low){ + cerr<<"histogram: high <= low"<<endl; usage(); return 1; } @@ -112,6 +118,11 @@ int main(int argc,char **argv){ histogram[binidx]=tally; if(tally>maxtally)maxtally=tally; + if(maxtally==0){ + cerr<<"histogram: No data in range"<<endl; + return 1; + } + char fullbar[BARWIDTH+1]; memset(fullbar,'#',BARWIDTH); fullbar[BARWIDTH]='\0'; |