home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / SMC21LIB.LZH / GETARG.C < prev    next >
Text File  |  2000-06-30  |  768b  |  33 lines

  1.  
  2. #define NOCCARGC
  3. #include stdio.h
  4. /*
  5. ** Get command line argument.
  6. ** Entry: n     = Number of the argument.
  7. **        s     = Destination string pointer.
  8. **        size  = Size of the destination string.
  9. **        argc  = Argument count from main().
  10. **        argv  = Argument vector(s) from main().
  11. ** Returns number of characters moved on success,
  12. ** else EOF.
  13. */
  14. getarg(n,s,size,argc,argv)
  15.   int n; char *s; int size, argc, argv[]; {
  16.   char *str;
  17.   int i;
  18.   if(n < 0 | n >= argc) {
  19.     *s = NULL;
  20.     return (EOF);
  21.     }
  22.   i = 0;
  23.   str=argv[n];
  24.   while(i<size) {
  25.     if((s[i]=str[i])==NULL) break;
  26.     ++i;
  27.     }
  28.   s[i]=NULL;
  29.   return (i);
  30.   }
  31.  
  32.  
  33.