home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 1 / FishNMoreVol1.bin / more / code_examples / librar / find_len.c < prev    next >
Text File  |  1989-02-08  |  971b  |  40 lines

  1. /*--------------------------------------*/
  2. /*                    */
  3. /*           FIND_LENGTH(X,X)        */
  4. /*                    */
  5. /* Functionality:            */
  6. /*    Finds the first byte starting    */
  7. /*    from the right of a character    */
  8. /*    array that is a non-blank.    */
  9. /* Arguments:                */
  10. /*    0: The character array.        */
  11. /*    1: Its length.            */
  12. /* Returns: The number of the byte    */
  13. /*        satisfying the above    */
  14. /*        condition.  A zero is    */
  15. /*        returned if no trailing    */
  16. /*        blanks are found.        */
  17. /* Author: John Callicotte        */
  18. /* Date created/modified: 09/01/88    */
  19. /*                    */
  20. /*--------------------------------------*/
  21.  
  22. find_length(a,b)
  23. int b;
  24. char a[];
  25. {
  26.         int flag,x,j;
  27.         flag=0;
  28.         x=b;
  29.         for (j=x-1;j>=0;j--){
  30.              if (a[j]!=32){
  31.                  x=j+1;
  32.                  flag=1;
  33.                  j=-1;
  34.              }
  35.         }
  36.         if (x==b && !flag)     /* Were there no trailing blanks? */
  37.             x=0;
  38.         return(x);
  39. }
  40.