Cover V01, I01
Article
Listing 1
Listing 10
Listing 11
Listing 12
Listing 13
Listing 14
Listing 15
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6
Listing 7
Listing 8
Listing 9

may92.tar


Listing 9

/*
*  checknum.c: written by Leor Zolman
*  Convert argument to number on standard output, or ERROR if none
*
*  Compile:
*     cc checknum.c -o checknum
*/

#include <stdio.h>

main(argc,argv)
char **argv;
{
int nvals, n;

if (argc < 2)
{
fprintf(stderr,"usage: %s text\n", argv[0]);
puts("ERROR");
exit (1);
}

nvals = sscanf(argv[1], "%d", &n);
if (!nvals)
{
puts("ERROR");
exit (1);
}
else
{
printf("%d", n);
exit (0);
}
}