Check the command line parameter: if less than required exit
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
double pounds;
if( argc != 2 ) {
printf("Usage: CONVERT <ounces>\n");
printf("Try Again");
exit(1); /* stop the program */
}
pounds = atof(argv[1]) / 16.0;
printf("%f pounds", pounds);
return 0;
}
Related examples in the same category