home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1557 / deleteline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  1.3 KB  |  62 lines

  1.  
  2. /*
  3.  * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
  4.  *
  5.  * Permission to use, copy, modify, and distribute this  software  and  its
  6.  * documentation is hereby  granted,  provided  that  the  above  copyright
  7.  * notice appear in all copies  and that  both  the  copyright  notice  and
  8.  * this permission notice appear in supporting documentation. This software
  9.  * is provided "as is" without express or implied  warranty.  However,  the
  10.  * author retains all Copyright priviliges and rights  to  renumeration  if
  11.  * this software is sold.
  12.  */
  13.  
  14. /*
  15.  * deleteline - delete a line from the text buffer
  16.  */
  17.  
  18. #include "simped.h"
  19.  
  20. char **deleteline(text, count, delline)
  21. char **text;
  22. int  *count;
  23. int  delline;        /* returns the line number deleted or 0 */
  24. {
  25. int    printf(),
  26.     fflush(),
  27.     puts(),
  28.     fputs();
  29.  
  30. void    free();
  31.  
  32. int    inpchar=0,
  33.     loop;
  34.  
  35. if(delline > 0)
  36.     {
  37.     printf("\n%3d> ",delline);
  38.     fputs(text[delline-1], stdout);
  39.     fputs("Delete this line (Return=n/y): ", stdout);
  40.     fflush(stdout);
  41.     inpchar=getchar();
  42.     putchar(inpchar);
  43.     }
  44.  
  45. if (inpchar == 'y' || inpchar == 'Y')
  46.     {
  47.     free(text[delline-1]);
  48.     for(loop=delline-1; loop < *count-1; ++loop)
  49.     {
  50.     text[loop] = text[loop+1];
  51.     }
  52.     text[loop]=NULL;
  53.     --*count;
  54.     puts("\nLine deleted.");
  55.     }
  56. else
  57.     {
  58.     puts("\nLine NOT deleted.");
  59.     }
  60. return(text);
  61. }
  62.