home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / SNIP9404.ZIP / ISISBN.C < prev    next >
C/C++ Source or Header  |  1994-04-03  |  505b  |  26 lines

  1. /*
  2. **  ISISBN.C - Validate International Standard Book Numbers (ISBNs)
  3. **
  4. **  public domain by Maynard Hogg
  5. */
  6.  
  7. #include <ctype.h>
  8.  
  9. int isbn2(char *str)
  10. {
  11.       int i = 0;
  12.       int test = 0;
  13.       int c;
  14.  
  15.       while ('\0' != (c = *str++))
  16.       {
  17.             if (isdigit(c))
  18.                   c -= '0';
  19.             else if (i == 9 && 'X' == c)
  20.                   c = 10;
  21.             else continue;
  22.             test += c * ++i;
  23.       }
  24.       return (i == 10 && test % 11 == 0);
  25. }
  26.