home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 344_02 / right.c < prev    next >
Text File  |  1990-05-20  |  1KB  |  38 lines

  1. /*
  2. HEADER:         ;
  3. TITLE:          BASIC like right() string function
  4. VERSION:        1.4;
  5.  
  6. DESCRIPTION:    provides BASIC like right() string function with
  7.                 similar syntax and return
  8.                 printf("%s\n",right(string,4)); would print the
  9.                 4 rightmost chars of string "string"
  10.  
  11. KEYWORDS:       BASIC,right,string;
  12. SYSTEM:         Xenix 3.4b, MSDOS;
  13. FILENAME:       right.c
  14. WARNINGS:       compile with -dNO_PROTOTYPE if your system does not
  15.                 support prototyping, with -dFOR_MSDOS if you are compiling
  16.                 for MSDOS with an ANSI standard compiler.
  17.                 Defaults assume compiling with prototypes for
  18.                 Xenix 3.4b on Altos 2086 computer.
  19.  
  20. SEE-ALSO:       demo.c;
  21. AUTHORS:        Vern Martin, 449 W. Harrison, Alliance, Ohio 44601;
  22. COMPILERS:      ECOSOFT ECO-C88, XENIX 3.4B STANDARD COMPILER;
  23. */
  24.  
  25. #include "vernmath.h"
  26.  
  27. char *right(string,len)
  28. char *string;
  29. int len;
  30. {
  31. /* local int */
  32.     int slen;
  33.  
  34.     slen = strlen(string);
  35.     if (len >= slen || len <= 0) return(string);
  36.     return( ( string + slen - len) );
  37. }
  38.