Can you help me about tolower() in file

This is a discussion on Can you help me about tolower() in file within the C Programming forums, part of the General Programming Boards category; Hi dear cprogramming users and staffs. I m writing a very simple text editor about my homework. I know you ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    5

    Can you help me about tolower() in file

    Hi dear cprogramming users and staffs. I m writing a very simple text editor about my homework. I know you dont like homework questions but mine is different.
    I wrote find , find-replace , save , about , new , open ... module. But i wasnt succes write a upper-lowercase. I want to all characters to lowercase in any file.
    If you help me about tolower() , i think , i can do toupper(). Sorry my bad english. Thank you .

  2. #2
    Registered User GL.Sam's Avatar
    Join Date
    Aug 2009
    Posts
    88
    I don't quite understand what help do you need. tolower() is a standard function from <ctype.h> header. If you want to apply it to an arbitrary string you could do something like:
    Code:
    void lower_string(char *str)
    {
      while (*str)
      {
        *str = tolower(*str);
        ++str;
      }
    }
    Last edited by GL.Sam; 05-12-2010 at 06:56 AM.
    The only good is knowledge and the only evil is ignorance.
    ~Socrates

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    5
    Thank you dear GL.Sam. You re right . I must write example code.

    In my menu
    at
    case 1 : tolower ()
    case 2 : delete_line()

    Code:
    case 1 :
                            
    tolower();/* at these , i want to  all words lowercase in a file*/
    break ;
    
    case 2 :
    
    delete_line() ;  /* delete line*/
    break ;
    "delete_line()" function is written by me and working perfect at "case 2" . But i want to call "tolower()" function at "case 1" for all words to lowercase in file (for example ; simple.txt) .

    How can i succes this ? Thank you .

  4. #4
    Registered User GL.Sam's Avatar
    Join Date
    Aug 2009
    Posts
    88
    So to achieve your goal you could use either buffering contents of the file to a temporary storage, applying tolower() to it and then rewriting the whole file, or updating the file just-in-time. Here's how it is done the second way:
    Code:
    #include <stdio.h>
    #include <ctype.h>
    #include <stdlib.h>
    
    
    int main(void)
    {
    	FILE *fp;
    	int ch, i = 0;
    
    	if ((fp = fopen("simple.txt", "r+")) == NULL)
    	{
    		fprintf(stderr, "Error opening the file.\n");
    		exit(EXIT_FAILURE);
    	}
    
    	while ((ch = fgetc(fp)) != EOF)
    	{
    		fseek(fp, i, SEEK_SET);
    		if (isupper(ch)) 
    			fputc(tolower(ch), fp);
    		fseek(fp, ++i, SEEK_SET);
    	}
    
    	fclose(fp);
    	return 0;
    }
    The only good is knowledge and the only evil is ignorance.
    ~Socrates

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    5
    I am grateful to you GL.Sam . I m trying now. I ll say result to you.

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    5
    I m sorry but again me

    i ll write my code as a full

    Code:
    # include "math.h"
    # include "dos.h"
    # include "process.h"
    # include "alloc.h"
    # include "stdlib.h"
    # include "stdio.h"
    # include "ctype.h"
    
    # include "util.c"
    # include "cursor.c"
    
    main ( int argc, char *argv[] )
    {
    
            
    	int flag ;
    
    	/* birden fazla dosya adı verildiğinde */
    	if ( argc > 2 )
    	{
    		printf ( "\nYanlis paramaetre!" ) ;
    		printf ( "\nBir tusa basin..." ) ;
    		fflush ( stdin ) ;
    		getch() ;
    		exit ( 1 ) ;
    	}
    
    	#ifdef CGA
    	{
    		vid_mem = ( char far * ) 0xb8000000L ;
    		textmode ( 3 ) ;
    	}
    	#else
    	{
    		vid_mem = ( char far * ) 0xb0000000L ;
    		textmode ( 7 ) ;
    	}
    	#endif
    
    	/* capture Ctrl - C interrupt */
    	old23 = getvect ( 0x23 ) ;
    	setvect ( 0x23, handler ) ;
    
    	/* capture Ctrl - Break interrupt */
    	old1b = getvect ( 0x1b ) ;
    	setvect ( 0x1b, handler ) ;
    
    	/* calculate the maximum buffer size */
    	maxsize = coreleft() - 5000 ;
    
    	/* ayrılan hafıza başarılı olduğunda */
    	buf = malloc ( maxsize ) ;
    	if ( buf == NULL )
    		error_exit() ;
    
    	
    	startloc = endloc = curscr = currow = buf ;
    
    	/* Insert tuşu */
    	*ins |= 0x80 ;
    
    	/* Varsayılan dosya ismi `isimsiz' */
    	strcpy ( filespec, "isimsiz" ) ;
    
    	workscreen() ;  /* Çalışan ekran görünümü */
    	displaymenuh ( mainmenu, 5 ) ;  /* Ana Menü ekranı */
    	about() ;  /* Hakkında ekranı */
    
    	/* Dosya isminin editörde değiştirilmesi halinde */
    	if ( argc == 2 )
    	{
    		/* dosya açılırsa */
    		strcpy ( filespec, argv[1] ) ;
    		flag = load() ;
    
    		/* dosya açılmassa*/
    		if ( flag == 0 )
    		{
    			strcpy ( filespec, "isimsiz" ) ;
    			write_fname() ;
    		}
    	}
    
    	while ( 1 )
    	{
    		gotoxy ( logc + 1, logr + 2 ) ;  /* cursor (imleç) pozisyonu */
    		getkey() ;  /* receive key */
    
    		/* Insert tuşunun ekranda görüntülenmesi */
    		if ( *ins & 0x80 )
    			writestring ( "Insert", 24, 73, 47 ) ;
    		else
    			writestring ( "      ", 24, 73, 112 ) ;
    
    		/* Özel tuş kullanımı */
    		if ( ascii == 0 )
    		{
    			/* Özel tuş kullanımı kontrolü */
    			switch ( scan )
    			{
    				case 59 :  /* F1  */
    
    					displayhelp ( 1 ) ;
    					break ;
    
    				case 60 :  /* F2 */
    
    					save() ;
    					break ;
    
    				case 45 :  /* Alt - X */
    
    					check_saved() ;
    					exit ( 0 ) ;
    
    				case 46 :  /* Alt - H */
    
    					/* renkli menü harfleri */
    					writestring ( mainmenu[0], 0, 2, 15 ) ;
    
    					/* imleç hareketleri servisi */
    					aserver() ;
    
    					/* renkli harflerin normal görünümü */
    					writestring ( mainmenu[0], 0, 2, 112 ) ;
    
    					break ;
    
    				case 33 :  /* Alt - F */
    
    					/* renkli menü harfleri */
    					writestring ( mainmenu[1], 0, 25, 15 ) ;
    
    					/* call file services */
    					fserver() ;
    
    					/* renkli harflerin normal görünümü */
    					writestring ( mainmenu[1], 0, 25, 112 ) ;
    
    					break ;
    
    				case 31 :  /* Alt - S */
    
    					writestring ( mainmenu[2], 0, 37, 15 ) ;
    					sserver() ;
    					writestring ( mainmenu[2], 0, 37, 112 ) ;
    					break ;
    
    				case 32 :  /* Alt - D */
    
    					writestring ( mainmenu[3], 0, 51, 15 ) ;
    					dserver() ;
    					writestring ( mainmenu[3], 0, 51, 112 ) ;
    					break ;
    
    				case 18 :  /* Alt - E */
    
    					writestring ( mainmenu[4], 0, 65, 15 ) ;
    					eserver() ;
    					writestring ( mainmenu[4], 0, 65, 112 ) ;
    					break ;
    
    				case 68 :  /* F10 */
    
    					mm_server() ;
    					break ;
    
    				case 93 :  /* Shift F10 */
    
    					about() ;
    					break ;
    
    				case 75 :  /* sol tuş */
    
    					left() ;
    					break ;
    
    				case 77 :  /* sağ tuş */
    
    					right() ;
    					break ;
    
    				case 72 :  /* yukarı tuşu */
    
    					up_line ( 1 ) ;
    					break ;
    
    				case 80 :  /* aşağı tuşu */
    
    					down_line ( 1 ) ;
    					break ;
    
    				case 73 :  /* PgUp */
    
    					page_up ( 1 ) ;
    					break ;
    
    				case 81 :  /* PgDn */
    
    					page_down() ;
    					break ;
    
    				case 71 :  /* Home */
    
    					start_line() ;
    					break ;
    
    				case 79 :  /* End */
    
    					end_line() ;
    					break ;
    
    				case 132 :  /* Ctrl - PgUp */
    
    					start_file() ;
    					break ;
    
    				case 118 :  /* Ctrl - PgDn */
    
    					end_file() ;
    					break ;
    
    				case 119 :  /* Ctrl - Home */
    
    					top_screen() ;
    					break ;
    
    				case 117 :  /* Ctrl - End */
    
    					bottom_screen() ;
    					break ;
    
    				case 115 :  /* Ctrl - sol tuş */
    
    					word_left() ;
    					break ;
    
    				case 116 :  /* Ctrl - sağ tuş */
    
    					word_right() ;
    					break ;
    
    				case 83 :  /* Del */
    
    					del_char() ;
    					break ;
    			}
    		}
    		else
    		{
    			switch ( ascii )
    			{
    				case 8 :  /* backspace */
    
    					backspace() ;
    					break ;
    
    				case 20 :  /* Ctrl - T */
    
    					del_word_rt() ;
    					break ;
    
    				/* case 25 :   Ctrl - Y 
    
                                          
                                          while((ch = getchar()) != EOF)
     
                                          	tolower(ch) ;
    					break ; */
    
    				case 12 :  /* Ctrl - L */
    
    					repeat_last() ;
    					break ;
    
    				default :
    
    					/* Karakterlerin doğrulanması durumunda */
    					if ( ( ascii >= 32 && ascii <= 126 ) || ascii == 13 || ascii == 9 )
    						displaychar ( ascii ) ;
    			}
    		}
    	}
    }
    
    /* Ana Menü ve seçenekler */
    mm_server()
    {
    	int mchoice, esc_flag ;
    
    	while ( 1 )
    	{
    		displaymenuh ( mainmenu, 5 ) ;
    		mchoice = getresponseh ( mainmenu, "CFSDE", 5 ) ;
    
    		switch ( mchoice )
    		{
    			case 1 :
    				esc_flag = aserver() ;
    				break ;
    
    			case 2 :
    				esc_flag = fserver() ;
    				break ;
    
    			case 3 :
    				esc_flag = sserver() ;
    				break ;
    
    			case 4 :
    				esc_flag = dserver() ;
    				break ;
    
    			case 5 :
    				esc_flag = eserver() ;
    				break ;
    
    			case ESC :  /* yatay menüde esc tuşu kullanımı */
    				esc_flag = ESC ;
    		}
    
    		/* dikey menüde esc tuşu kullanımı */
    		if ( esc_flag == ESC )
    			return ( esc_flag ) ;
    	}
    }
    
    /* Hakkında Menüsü (imleç servisi içinde) */
    aserver()
    {
    	int cchoice, esc_flag = 0 ;
    
    	/* hakkında menüsü açılımı */
    	cchoice = popupmenuv ( hakkindamenu, 1, 1, 0, "HE", 1 ) ;
    
    	/* alt menüde fonksiyon çağırma */
    	switch ( cchoice )
    	{
    		case 1 :
    			start_file() ;
    			break ;
    
    
    		case 2 :
    
    			/* ana menü çağırma */
    			esc_flag = mm_server() ;
    
    			break ;
    
    		case 75 :  /* sol tuş */
    
    			/* make the `Cursor Movement' menu item normal */
    			writestring ( mainmenu[0], 0, 2, 112 ) ;
    
    			/* 'Çıkış' menüsü renklendirme */
    			writestring ( mainmenu[4], 0, 65, 15 ) ;
    
    			/* çıkış fonk. çağırma */
    			esc_flag = eserver() ;
    
    			/* 'Çıkış' menüsü normal */
    			writestring ( mainmenu[4], 0, 65, 112 ) ;
    
    			break ;
    
    		case 77 :  /* sağ tuş */
    
    			/* `Hakkında' menüsü normal*/
    			writestring ( mainmenu[0], 0, 2, 112 ) ;
    
    			/* `Dosya' menüsü renklendirme */
    			writestring ( mainmenu[1], 0, 25, 15 ) ;
    
    			/* Dosya servisi çağırma */
    			esc_flag = fserver() ;
    
    			/*`Dosya' menüsü normal */
    			writestring ( mainmenu[1], 0, 25, 112 ) ;
    
    			break ;
    
    		case ESC :
    			esc_flag = ESC ;
    	}
    
    	return ( esc_flag ) ;
    }
    
    /* Dosya menüsü görünümü ve alt fonksiyonların çağırılması */
    fserver()
    {
    	int fchoice, flag, esc_flag = 0 ;
    	char fname[30] ;
    
    	fchoice = popupmenuv ( dosyamenu, 7, 1, 23, "LPNSAMCOT", 3 ) ;
    
    	switch ( fchoice )
    	{
    		case 1 :
    
    			check_saved() ;  /* Dosyanın kaydını kontrol etme */
    			strcpy ( fname, filespec ) ;
    
    			/* Açılan dosya adı */
    			esc_flag = ask_name ( "Dosya adini giriniz", filespec ) ;
    			if ( esc_flag == ESC )
    				break ;
    
    			flag = load() ;  /* Dosya aç */
    
    			/* Dosya açımında hata */
    			if ( flag == 0 )
    			{
    				strcpy ( filespec, fname ) ;
    				write_fname() ;
    			}
    
    			break ;
    
    		case 2 :
    			pick() ;  /* hafızadan dosya açma */
    			break ;
    
    		case 3 :
    			new() ;  /* yeni dosya */
    			break ;
    
    		case 4 :
    			save() ;  /* dosyayı kaydetme */
    			break ;
    
    		case 5 :
    			save_as() ;  /* yeni isimle kaydetme */
    			break ;
    
    		case 6 :
    			merge() ;  /* varolan dosya içerisinde başka dosyayı okuma (birleştirme) */
    			break ;
    
    		case 7 :
    			change_dir() ;  /* Ana dizini değiştirme */
    			break ;
    
    		case 8 :
    			print() ;  /* Dosyayı yazdırma */
    			break ;
    
    		case 9 :
    
    			/* ama menü servislerini çağırma */
    			esc_flag = mm_server() ;
    
    			break ;
    
    		case 75 :  /* sol tuş */
    
    			/* Hakkında menüsü görüntüleme */
    			writestring ( mainmenu[1], 0, 25, 112 ) ;
    			writestring ( mainmenu[0], 0, 2, 15 ) ;
    			esc_flag = aserver() ;
    			writestring ( mainmenu[0], 0, 2, 112 ) ;
    
    			break ;
    
    		case 77 :  /* sağ tuş */
    
    			/* Arama menüsü görüntüleme */
    			writestring ( mainmenu[1], 0, 25, 112 ) ;
    			writestring ( mainmenu[2], 0, 37, 15 ) ;
    			esc_flag = sserver() ;
    			writestring ( mainmenu[2], 0, 37, 112 ) ;
    
    			break ;
    
    		case ESC :
    			esc_flag = ESC ;
    	}
    
    	return ( esc_flag ) ;
    }
    
    /* Arama menüsü görüntüleme ve servislerini çağırma */
    sserver()
    {
    	int schoice, esc_flag = 0 ;
    
    	schoice = popupmenuv ( aramamenu, 3, 1, 35, "FRLAGT", 4 ) ;
    
    	switch ( schoice )
    	{
    		case 1 :
    
    			/* uygun arama kriterini girme */
    			findflag = 1 ;
    			frflag = 0 ;
    
    			find() ;  /* arama stringi */
    			break ;
    
    		case 2 :
    
    			/* uygun arama kriterini girme */
    			findflag = 0 ;
    			frflag = 1 ;
    
    			replace() ;  /* bul ve değiştir stringi */
    			break ;
    
    		case 3 :
    			repeat_last() ;  /* son aramayı tekrarlama */
    			break ;
    
    		case 4 :
    			abort_find() ;  /* çıkış işlemini sonlandırma */
    			break ;
    
    		case 5 :
    			gotoline() ;  /* satıra git */
    			break ;
    
    		case 6 :
    
    			/* ana menü servislerini çağırma */
    			esc_flag = mm_server() ;
    
    			break ;
    
    		case 75 :  /* sol tuş */
    
    			/* Dosya menüsü gösterimi */
    			writestring ( mainmenu[2], 0, 37, 112 ) ;
    			writestring ( mainmenu[1], 0, 25, 15 ) ;
    			esc_flag = fserver() ;
    			writestring ( mainmenu[1], 0, 25, 112 ) ;
    
    			break ;
    
    		case 77 :  /* sağ tuş */
    
    			/* Düzen menüsü gösterimi */
    			writestring ( mainmenu[2], 0, 37, 112 ) ;
    			writestring ( mainmenu[3], 0, 51, 15 ) ;
    			esc_flag = dserver() ;
    			writestring ( mainmenu[3], 0, 51, 112 ) ;
    
    			break ;
    
    		case ESC :
    			esc_flag = ESC ;
    	}
    
    	return ( esc_flag ) ;
    }
    
    /* Düzen menüsü gösterimi ve servislerin çağırımı */
    dserver()
    {
                    FILE *fp;
    	int ch, i = 0;	int dchoice, esc_flag = 0 ;
            
    
    	dchoice = popupmenuv ( duzenmenu, 3, 1, 49, "DEBRT", 5 ) ;
    
    	switch ( dchoice )
    	{
    		case 1 :
                     while ((ch = fgetc(fp)) != EOF)  
                    {
    		fseek(fp, i, SEEK_SET);
    		if (isupper(ch)) 
    			fputc(tolower(ch), fp);
    		fseek(fp, ++i, SEEK_SET);
    	        }
    
    	        break ;
    
    		case 2 :
    			del_line_rt() ;  /* tümü küçük */
    			break ;
    
    		case 3 :
    			del_line_lt() ;  /* İstatistik */
    			break ;
    
    		case 4 :
    
    			/* ana menü servislerini çağırma */
    			esc_flag = mm_server() ;
    
    			break ;
    
    		case 75 :  /* sol tuş */
    
    			/* display Search menu */
    			writestring ( mainmenu[3], 0, 51, 112 ) ;
    			writestring ( mainmenu[2], 0, 37, 15 ) ;
    			esc_flag = sserver() ;
    			writestring ( mainmenu[2], 0, 37, 112 ) ;
    
    			break ;
    
    		case 77 :  /* sağ tuş */
    
    			/* Çıkıç menüsü gösterimi */
    			writestring ( mainmenu[3], 0, 51, 112 ) ;
    			writestring ( mainmenu[4], 0, 65, 15 ) ;
    			esc_flag = eserver() ;
    			writestring ( mainmenu[4], 0, 65, 112 ) ;
    
    			break ;
    
    		case ESC :
    			esc_flag = ESC ;
    	}
    
    	return ( esc_flag ) ;
    }
    
    /* Çıkış menüsü gösterimi ve servisleri çağırma */
    eserver()
    {
    	int fchoice, esc_flag ;
    
    	fchoice = popupmenuv ( cikismenu, 1, 1, 62, "EST", 6 ) ;
    
    	switch ( fchoice )
    	{
    		case 1 :
    
    			/* dosyanın kaydedildiğini kontrol etme */
    			check_saved() ;
    
    			/* Kesme vektörlerini eski haline döndürme */
    			setvect ( 0x23, old23 ) ;
    			setvect ( 0x1b, old1b ) ;
    
    			/* Çıkış */
    			exit ( 0 ) ;
    
    		case 2 :
    			shell() ;  /* Çıkış */
    			break ;
    
    		case 3 :
    
    			/* ana menü servislerini çağırma */
    			esc_flag = mm_server() ;
    
    			break ;
    
    		case 75 :  /* lsol tuş */
    
    			/* Düzen menüsü gösterimi */
    			writestring ( mainmenu[4], 0, 65, 112 ) ;
    			writestring ( mainmenu[3], 0, 51, 15 ) ;
    			esc_flag = dserver() ;
    			writestring ( mainmenu[3], 0, 51, 112 ) ;
    
    			break ;
    
    		case 77 :  /* sağ tuş */
    
    			/* hakkında menüsü gösterimi */
    			writestring ( mainmenu[4], 0, 65, 112 ) ;
    			writestring ( mainmenu[0], 0, 2, 15 ) ;
    			esc_flag = aserver() ;
    			writestring ( mainmenu[0], 0, 2, 112 ) ;
    
    			break ;
    
    		case ESC :
    			esc_flag = ESC ;
    	}
    
    	return ( esc_flag ) ;
    }
    
    /* Çalışma ekranı oluşturma */
    workscreen()
    {
    	size ( 32, 0 ) ;
    
    	/* Doldurma kutusu çizimi */
    	menubox ( 1, 0, 23, 79, 27, NO_SHADOW ) ;
    
    	/* Kutu çerçevesi çizimi */
    	drawbox ( 1, 0, 23, 79, 27 ) ;
    
    	/* varolan dosyayı görüntüleme ör: "isimsiz" */
    	write_fname() ;
    
    	/* farklı renklerde kutu çizimi */
    	menubox ( 24, 0, 24, 79, 112, NO_SHADOW ) ;
    
    	/* Bazı özel tuşları görüntüleme */
    	status_line() ;
    
    	size ( 5, 7 ) ;
    }
    
    /* hakkında ekranı */
    about()
    {
    	int area ;
    	char *p ;
    
    	size ( 32, 0 ) ;  /* cursoru sakla */
    
    	/* hafıza ayırma başarısız olursa */
    	area = ( 17 - 6 + 1 ) * ( 60 - 19 + 1 ) * 2 ;
    	p = malloc ( area ) ;
    	if ( p == NULL )
    		error_exit() ;
    
    	/* dialog kutusu oluşturma */
    	savevideo ( 6, 19, 17, 60, p ) ;
    	menubox ( 6, 19, 17, 60, 112, 7 ) ;
    	drawbox ( 6, 19, 16, 58 , 112 ) ;
    
    	writestring ( "NcEdit", 7, 35, 112 ) ;
    	writestring ( "Versiyon 1.00", 9, 33, 112 ) ;
    	writestring ( "Dizayn ve Olusturulma", 10, 27, 112 ) ;
    	writestring ( "Nc Pc Lab.", 11, 28, 112 ) ;
    	writestring ( "Tesekkurler", 12, 32, 112 ) ;
    
    	/* Tamam tuşu */
    	menubox ( 14, 36, 15, 43, 32, HALF_SHADOW ) ;
    	writestring ( "OK", 14, 38, 47 ) ;
    
    	/* continue till either Esc is hit or OK is selected */
    	while ( 1 )
    	{
    		getkey() ;
    
    		if ( ascii == ESC || ascii != 'O' || ascii == 'o' )
    			break ;
    	}
    
    	restorevideo ( 6, 19, 17, 60, p ) ;
    	free ( p ) ;
    
    	size ( 5, 7 ) ;  /* cursoru göster */
    }
    
    /* dosya ismini yaz */
    write_fname()
    {
    	int len ;
    	char drive[2], fname[9], ext[5] ;
    
    	size ( 32, 0 ) ;  /* hide cursor */
    
    	/* draw the enclosing box */
    	drawbox ( 1, 0, 23, 79, 27 ) ;
    
    	/* display current cursor location */
    	writecol() ;
    	writerow() ;
    
    	/* find drive name */
    	if ( filespec[1] == ':' )
    		drive[0] = filespec[0] ;
    	else
    		drive[0] = getdisk() + 65 ;
    	drive[1] = '\0' ;
    
    	fnsplit ( filespec, "", "", fname, ext ) ;
    
    	strcpy ( filename, " " ) ;
    	strcat ( filename, drive ) ;
    	strcat ( filename, ":" ) ;
    	strcat ( filename, fname ) ;
    
    	/* if extension exists */
    	if ( ext[0] )
    		strcat ( filename, ext ) ;
    
    	strcat ( filename, " " ) ;
    	strupr ( filename ) ;
    
    	/* display file name */
    	len = strlen ( filename ) ;
    	writestring ( filename, 1, 39 - len / 2, 27 ) ;
    
    	size ( 5, 7 ) ;  /* show cursor */
    }
    
    /* displays current row number */
    writerow()
    {
    	int i ;
    	char s[10] ;
    
    	/* overwrite currently displayed row number */
    	for ( i = 0 ; i <= 3 ; i++ )
    		writechar ( 23, 60 + i, 205, 27 ) ;
    
    	/* display current row number */
    	itoa ( curr - 1, s, 10 ) ;
    	writestring ( s, 23, 64 - strlen ( s ), 15 ) ;
    	writechar ( 23, 64, ':', 15 ) ;
    
    	/* position the cursor */
    	gotoxy ( logc + 1, logr + 2 ) ;
    }
    
    /* displays current column number */
    writecol()
    {
    	int i ;
    	char s[10] ;
    
    	/* overwrite currently displayed column number */
    	for ( i = 0 ; i <= 2 ; i++ )
    		writechar ( 23, 65 + i, 205, 27 ) ;
    
    	/* display current column number */
    	itoa ( curc, s, 10 ) ;
    	writestring ( s, 23, 65, 15 ) ;
    	writechar ( 23, 64, ':', 15 ) ;
    
    	/* position the cursor */
    	gotoxy ( logc + 1, logr + 2 ) ;
    }
    
    /* displays certain special keys and their significance */
    status_line()
    {
    	menubox ( 24, 0, 24, 79, 112, NO_SHADOW ) ;
    	writestring ( "^F^1-Help   ^F^2-Save   ^S^h^-^F^1^0-Product Info ^A^l^t^-^X-Exit", 24, 1, 112 ) ;
    
    	/* display current status of Ins key */
    	if ( *ins & 0x80 )
    		writestring ( "Insert", 24, 73, 47 ) ;
    }
    
    /* displays a message and collects the string entered in response */
    ask_name ( char *str, char *name )
    {
    	int area, esc_flag, len ;
    	char *p, currentdir[31] ;
    
    	/* allocate memory, if unsuccessful terminate execution */
    	area = ( 17 - 7 + 1 ) * ( 62 - 17 + 1 ) * 2 ;
    	p = malloc ( area ) ;
    	if ( p == NULL )
    		error_exit() ;
    
    	/* create dialogue box */
    	savevideo ( 7, 17, 17, 62, p ) ;
    	menubox ( 7, 17, 17, 62, 112, 7 ) ;
    	drawbox ( 7, 17, 16, 60 , 112 ) ;
    
    	len = strlen ( str ) ;
    	writestring ( str, 9, 39 - len / 2, 112 ) ;
    
    	menubox ( 11, 21, 12, 56, 32, HALF_SHADOW ) ;
    
    	/* if directory name is to be entered, display current directory */
    	if ( strcmp ( str, "Enter directory name" ) == 0 )
    	{
    		getcwd ( currentdir, 30 ) ;
    		writestring ( currentdir, 11, 22, 47 ) ;
    	}
    
    	menubox ( 14, 27, 15, 51, 32, HALF_SHADOW ) ;
    	writestring ( "Press Esc to cancel", 14, 29, 47 ) ;
    
    	/* collect the string entered */
    	esc_flag = getname ( 11, 22, name ) ;
    
    	restorevideo ( 7, 17, 17, 62, p ) ;
    	free ( p ) ;
    	return ( esc_flag ) ;
    }
    
    /* collects a string from keyboard */
    getname ( int row, int col, char *p )
    {
    	int i = 0 ;
    	char str[30] ;
    
    	size ( 5, 7 ) ;
    
    	/* continue to collect characters until Esc or Enter key is hit */
    	while ( 1 )
    	{
    		gotoxy ( col + i + 1, row + 1 ) ;
    		getkey() ;
    
    		if ( ascii == 27 )
    			return ( ESC ) ;
    
    		/* if current directory name is displayed, erase it */
    		if ( i == 0 )
    			menubox ( 11, 21, 12, 56, 32, HALF_SHADOW ) ;
    
    		/* if Enter is hit or more than 30 characters have been entered */
    		if ( ascii == 13 || i > 30 )
    			break ;
    
    		/* if backspace key is hit */
    		if ( ascii == '\b' )
    		{
    			/* if at least one character has been entered */
    			if ( i != 0 )
    			{
    				i-- ;
    				writechar ( row, col + i, ' ', 47 ) ;
    			}
    		}
    
    		/* if a valid ascii character and not a control character */
    		if ( isascii ( ascii ) && ! iscntrl ( ascii ) )
    		{
    			str[i] = ascii ;
    			writechar ( row, col + i, ascii, 47 ) ;
    			i++ ;
    		}
    	}
    
    	str[i] = '\0' ;  /* terminate string */
    	strcpy ( p, str ) ;
    	size ( 32, 0 ) ;
    	return ( 0 ) ;
    }
    
    /* displays message strings passed to it */
    message ( char *str1, char *str2 )
    {
    	int area, len ;
    	char *p ;
    
    	size ( 32, 0 ) ;
    
    	/* allocate memory, if unsuccessful terminate execution */
    	area = ( 17 - 8 + 1 ) * ( 60 - 19 + 1 ) * 2 ;
    	p = malloc ( area ) ;
    	if ( p == NULL )
    		error_exit() ;
    
    	/* create dialogue box */
    	savevideo ( 8, 19, 16, 60, p ) ;
    	menubox ( 8, 19, 16, 60, 112, 7 ) ;
    	drawbox ( 8, 19, 15, 58 , 112 ) ;
    
    	writestring ( filename, 10, 25, 112 ) ;
    
    	/* display the two strings */
    	writestring ( str1, 10, 26 + strlen ( filename ), 112 ) ;
    	len = strlen ( str2 ) ;
    	writestring ( str2, 11, 39 - len / 2, 112 ) ;
    
    	/* display Yes, No and Cancel buttons */
    	menubox ( 13, 24, 14, 30, 32, HALF_SHADOW ) ;
    	writestring ( " $Yes ", 13, 24, 32 ) ;
    	menubox ( 13, 44, 14, 53, 32, HALF_SHADOW ) ;
    	writestring ( " $Cancel ", 13, 44, 32 ) ;
    	menubox ( 13, 34, 14, 39, 32, HALF_SHADOW ) ;
    	writestring ( " $No ", 13, 34, 32 ) ;
    
    	/* continue till Y, N or C is hit */
    	while ( 1 )
    	{
    		getkey() ;
    		ascii = toupper ( ascii ) ;
    		if ( ascii == 'Y' || ascii == 'N' || ascii == 'C' )
    			break ;
    	}
    
    	restorevideo ( 8, 19, 16, 60, p ) ;
    	free ( p ) ;
    
    	size ( 5, 7 ) ;
    	return ( ascii ) ;
    }
    
    /* loads the specified file in memory */
    load()
    {
    	FILE *fp ;
    	int i = 0, flag = 0 ;
    	char ans = 'N', *temp ;
    
    	temp = endloc ;
    	saved = YES ;
    	menubox ( 24, 0, 24, 79, 112, NO_SHADOW ) ;
    	write_fname() ;  /* write the name of the file */
    	writestring ( "Loading Editor File...", 24, 1, 112 ) ;
    
    	/* initialise endloc so that it points to the beginning of buffer */
    	endloc = buf ;
    
    	/* open the specified file */
    	fp = fopen ( filespec, "r" ) ;
    
    	/* if unable to open file */
    	if ( fp == NULL )
    	{
    		menubox ( 24, 0, 24, 79, 112, NO_SHADOW ) ;
    
    		/* ask whether to create a new file */
    		ans = message ( "does not exist...", "Create ?" ) ;  
    	}
    	else
    	{
    		/* read file contents into buffer */
    		while ( ( buf[i] = getc ( fp ) ) != EOF )
    		{
    			i++ ;
    
    			/* if the file size exceeds the buffer size */
    			if ( i == maxsize )
    			{
    				ans = message ( "too large!", "Truncate ?" ) ;
    
    				/* if file is to be truncated */
    				if ( ans == 'Y' )
    					break ;
    				else
    				{
    					endloc = temp ;
    					status_line() ;
    					return ( 0 ) ;
    				}
    			}
    
    			endloc++ ;
    		}
    	}
    
    	/* if loading was successful or if new file is to be created */
    	if ( fp != NULL || ans == 'Y' )
    	{
    		/* reset variables */
    		curr = 2 ;
    		curc = 1 ;
    		logr = 1 ;
    		logc = 1 ;
    		skip = 0 ;
    		startloc = curscr = currow = buf ;
    
    		/* display current cursor location */
    		writerow() ;
    		writecol() ;
    
    		/* clear previous screen contents */
    		menubox ( 2, 1, 22, 78, 27, NO_SHADOW ) ;
    
    		/* display one screen-full (or less) of loaded file */
    		displayscreen ( curscr ) ;
    
            /* store the name of the file in the pick list */
    		strcpy ( pickfile[pickfileno], filespec ) ;  
    
    		pickfileno++ ;  /* increment the number of pick files */
    
    		if ( pickfileno > 4 )  /* a maximum of 5 files are present in the pick list */
    			pickfileno = 0 ;
    
    		flag = 1 ;
    		status_line() ;
    	}
    	else
    	{
    		endloc = temp ;
    		status_line() ;
    		return ( 0 ) ;
    	}
    
    	/* close the file */
    	fclose ( fp ) ;
    
    	return ( flag ) ;
    }
    
    /* checks if current file is saved or not */
    check_saved()
    {
    	char ans ;
    
    	/* if file is not saved */
    	if ( saved == NO )
    	{
    		ans = message ( "is not saved...", "Save ?" ) ;
    
    		if ( ans == 'Y' )
    			save() ;
    	}
    }
    
    /* displays a line and returns 0 if end of file is encountered while printing that line and returns 1 otherwise */
    displayline ( char *p, int row )
    {
    	int col, tabflag = 0, i, num ;
    
    	if ( p >= endloc )
    		return ( 0 ) ;
    
    	num = skip ;
    
    	/* skip past `skip' number of characters at the beginning of the line */
    	for ( i = 1 ; i <= skip ; i++ )
    	{
    		/* if a newline is encountered */
    		if ( *p == '\n' )
    			return ( 1 ) ;
    
    		/* if a tab is encountered */
    		if ( *p == '\t' )
    		{
    			/* if less than 8 characters remain to be skipped */
    			if ( num <= 8 )
    				tabflag = 1 ;
    			else
    			{
    				/* skip past the tab */
    				i += 7 ;
    				num -= 8 ;
    
    				p++ ;
    				if ( p >= endloc )
    					return ( 0 ) ;
    			}
    		}
    		else
    		{
    			p++ ;
    			if ( p >= endloc )
    				return ( 0 ) ;
    		}
    	}
    
    	/* display the line */
    	for ( col = 1 ; col < 79 ; col++ )
    	{
    		if ( *p == '\n' )
    			return ( 1 ) ;
    
    		if ( *p == '\t' )
    		{
    			if ( tabflag )
    			{
    				col += ( 7 - num ) ;  /* leave spaces representing part of the tab not scrolled past horizontally */
    				tabflag = 0 ;
    			}
    			else
    				col += 7 ;
    		}
    		else
    			writechar ( row, col, *p, 27 ) ;
    
    		p++ ;
    		if ( p >= endloc )
    			return ( 0 ) ;
    	}
    
    	return ( 1 ) ;
    }
    
    /* displays one screen full (or less) of file contents on screen */
    displayscreen ( char *p )
    {
    	int row, status ;
    
    	for ( row = 2 ; row < 23 ; row++ )
    	{
    		/* print one line */
    		status = displayline ( p, row ) ;
    
    		/* if end of file is reached while printing the line */
    		if ( status == 0 )
    			return ( 0 ) ;
    
    		/* increment the pointer to point to the beginning of next line */
    		while ( *p != '\n' )
    		{
    			p++ ;
    
    			/* if p reaches beyond the last character in the file */
    			if ( p >= endloc )
    				return ( 0 ) ;
    		}
    		p++ ;
    
    		/* if p reaches beyond the last character in the file */
    		if ( p >= endloc )
    			return ( 0 ) ;
    	}
    }
    
    /* loads selected file from the pick list */
    pick()
    {
    	int choice, flag ;
    	char fname[31] ;
    
    	/* if pick list is empty */
    	if ( pickfileno == 0 )
    		return ;
    
    	strcpy ( fname, filespec ) ;
    
    	/* pop up pick file list */
    	choice = popupmenuv ( pickfile, pickfileno, 1, 23, "", 7 ) ;
    
    	/* if file is selected from the popped pick list */
    	if ( choice != ESC )
    	{
    		/* check if current file has been saved */
    		check_saved() ;
    		strcpy ( filespec, pickfile[choice - 1] ) ;
    
    		/* load file into buffer */
    		flag = load() ;
    
    		/* if unable to load file */
    		if ( flag == 0 )
    		{
    			strcpy ( filespec, fname ) ;
    			write_fname() ;
    		}
    	}
    }
    
    /* sets up a new file for editing */
    new()
    {
    	/* check if current file has been saved */
    	check_saved() ;
    
    	/* set up `NONAME' as the default file name */
    	strcpy ( filespec, "NONAME" ) ;
    	write_fname() ;
    
    	/* reset variables */
    	curr = 2 ;
    	curc = 1 ;
    	logr = 1 ;
    	logc = 1 ;
    	saved = YES ;
    
    	/* initialise pointers so that they point to the beginning of buffer */
    	startloc = endloc = curscr = currow = buf ;
    
    	/* clear previous screen contents */
    	menubox ( 2, 1, 22, 78, 27, NO_SHADOW ) ;
    
    	/* display current cursor location */
    	writecol() ;
    	writerow() ;
    }
    
    /* stores a file on disk */
    save()
    {
    	FILE *fp ;
    	char *p ;
    
    	size ( 32, 0 ) ;
    
    	/* if current file name is `NONAME' */
    	if ( strcmp ( filespec, "NONAME" ) == 0 )
    	{
    		/* ask for the new file name */
    		ask_name ( "Enter file name", filespec ) ;
    
    		/* write new file name */
    		write_fname() ;
    
    		/* add new file name to pick list */
    		strcpy ( pickfile[pickfileno], filespec ) ;
    		pickfileno++ ;
    		if ( pickfileno > 4 )
    			pickfileno = 0 ;
    	}
    
    	/* open file for writing and check if successful */
    	fp = fopen ( filespec, "w" ) ;
    	if ( fp == NULL )
    	{
    		message ( "File creation error", "Return ?" ) ;
    		return ( 0 ) ;
    	}
    
    	menubox ( 24, 0, 24, 79, 112, NO_SHADOW ) ;
    	writestring ( "Saving Editor File...", 24, 1, 112 ) ;
    
    	p = startloc ;
    
    	/* write each character in the buffer into file */
    	while ( p != endloc )
    	{
    		putc ( *p, fp ) ;
    		p++ ;
    	}
    
    	fclose ( fp ) ;
    	saved = YES ;
    	status_line() ;  /* display status line */
    	size ( 5, 7 ) ;
    	return ( 1 ) ;
    }
    
    /* saves the curent file under a new name */
    save_as()
    {
    	int success ;
    
    	size ( 32, 0 ) ;
    
    	/* receive the new file name */
    	ask_name ( "Enter new file name", filespec ) ;
    
    	success = save() ;  /* save the file under new name */
    
    	if ( success )
    	{
    		/* display new file name */
    		write_fname() ;
    
    		/* update pick list */
    		strcpy ( pickfile[pickfileno], filespec ) ;
    		pickfileno++ ;
    		if ( pickfileno > 4 )
    			pickfileno = 0 ;
    	}
    
    	size ( 5, 7 ) ;
    }
    
    /* merges another file into current file at current cursor location */
    merge()
    {
    	int col, i ;
    	unsigned count = 0 ;
    	unsigned long totalsize ;
    	FILE *fp ;
    	char ans, str[17], *temp ;
    
    	size ( 32, 0 ) ;
    
    	strcpy ( str, filename ) ;
    
    	/* receive name of file to merge */
    	ask_name ( "Enter file name", filename ) ;
    
    	/* open file and check if successful in opening */
    	fp = fopen ( filename, "r" ) ;
    	if ( fp == NULL )
    	{
    		message ( "does not exist...", "OK ?" ) ;
    		strcpy ( filename, str ) ;
    		return ;
    	}
    
    	/* count characters in file to be merged */
    	while ( getc ( fp ) != EOF )
    		count++ ;
    
    	totalsize = ( unsigned ) ( endloc - startloc ) ;
    	totalsize += count ;
    
    	/* check if file size exceeds the buffer size on merging */
    	if ( totalsize >= maxsize )
    	{
    		ans = message ( "too large!", "Truncate ?" ) ;
    
    		/* if file is to be truncated */
    		if ( ans == 'Y' )
    			count = maxsize - ( unsigned ) ( endloc - startloc ) ;
    		else
    			return ;
    	}
    
    	/* increment `temp' to point to character at current cursor location */
    	temp = currow ;
    	for ( col = 1 ; col < curc ; col++ )
    	{
    		if ( *temp == '\t' )
    			col += 7 ;
    
    		if ( *temp == '\n' || temp == endloc )
    			break ;
    
    		temp++ ;
    	}
    
    	/* move characters after `temp' ahead by `count' bytes */
    	memmove ( temp + count , temp, endloc - temp ) ;
    
    	/* update ending location pointer */
    	endloc += count ;
    
    	saved = NO ;
    
    	/* read the file to be merged into the buffer */
    	rewind ( fp ) ;
    	for ( i = 0 ; i < count ; i++ )
    	{
    		*temp = getc ( fp ) ;
    		temp++ ;
    	}
    
    	/* clear screen contents from current row onwards */
    	menubox ( logr + 1, 1, 22, 78, 27, NO_SHADOW ) ;
    
    	/* update screen contents */
    	displayscreen ( curscr ) ;
    
    	strcpy ( filename, str ) ;
    
    	size ( 5, 7 ) ;
    }
    
    /* changes default directory */
    change_dir()
    {
    	char dirname[31], *p ;
    	int status, area, esc_flag ;
    
    	/* collect directory name */
    	esc_flag = ask_name ( "Enter directory name", dirname ) ;
    	if ( esc_flag )
    		return ;
    
    	status = chdir ( dirname ) ;
    
    	/* allocate memory, if unsuccessful terminate execution */
    	area = ( 17 - 8 + 1 ) * ( 60 - 19 + 1 ) * 2 ;
    	p = malloc ( area ) ;
    	if ( p == NULL )
    		error_exit() ;
    
    	/* create dialogue box */
    	savevideo ( 8, 19, 16, 60, p ) ;
    	menubox ( 8, 19, 16, 60, 112, 7 ) ;
    	drawbox ( 8, 19, 15, 58 , 112 ) ;
    
    	menubox ( 10, 21, 11, 56, 32, HALF_SHADOW ) ;
    	menubox ( 13, 21, 14, 56, 32, HALF_SHADOW ) ;
    
    	/* check if successful in changing directory */
    	if ( status == 0 )
    	{
    		writestring ( "Directory sucessfully changed", 10, 22, 47 ) ;
    		write_fname() ;
    	}
    	else
    		writestring ( "Error in changing directory", 10, 22, 47 ) ;
    
    	writestring ( "Press any key...", 13, 22, 47 ) ;
    	fflush ( stdin ) ;
    	getch() ;
    
    	restorevideo ( 8, 19, 16, 60, p ) ;
    	free ( p ) ;
    }
    
    /* prints the file on printer */
    print()
    {
    	int area, tm, bm, pl, i, row = 1, esc_flag, top_of_page = 1 ;
    	char *p, ch, topmargin[3], botmargin[3], pagelength[3], fname[31] ;
    	FILE *fs ;
    
    	/* receive the file name */
    	esc_flag = ask_name ( "Enter file name", fname ) ;
    	if ( esc_flag )
    		return ;
    
    	/* allocate memory, if unsuccessful terminate execution */
    	area = ( 17 - 8 + 1 ) * ( 60 - 19 + 1 ) * 2 ;
    	p = malloc ( area ) ;
    	if ( p == NULL )
    		error_exit() ;
    
    	/* create dialogue box */
    	savevideo ( 8, 19, 16, 60, p ) ;
    	menubox ( 8, 19, 15, 60, 112, 7 ) ;
    	drawbox ( 8, 19, 14, 58 , 112 ) ;
    
    	/* open file and check if successful */
    	fs = fopen ( fname, "r" ) ;
    	if ( fs == NULL )
    	{
    		writestring ( "Unable to open", 10, 25, 112 ) ;
    		writestring ( fname, 10, 40, 112 ) ;
    		writestring ( "Press any key to return...", 11, 24, 112 ) ;
    		fflush ( stdin ) ;
    		getch() ;
    		restorevideo ( 8, 19, 16, 60, p ) ;
    		free ( p ) ;
    		return ;
    	}
    
    	/* collect page specifications */
    	esc_flag = ask_name ( "Top Margin", topmargin ) ;
    	esc_flag = ask_name ( "Bottom Margin", botmargin ) ;
    	esc_flag = ask_name ( "Page Length", pagelength ) ;
    
    	tm = atoi ( topmargin ) ;
    	bm = atoi ( botmargin ) ;
    	pl = atoi ( pagelength ) ;
    
    	writestring ( "Set up the printer", 9, 27, 112 ) ;
    	writestring ( "Press any key when ready...", 10, 25, 112 ) ;
    	menubox ( 12, 27, 13, 51, 32, HALF_SHADOW ) ;
    	writestring ( "Press Esc to cancel", 12, 29, 47 ) ;
    	getkey() ;
    	restorevideo ( 8, 19, 16, 60, p ) ;
    	free ( p ) ;
    
    	if ( ascii == ESC )
    		return ;
    
    	/* continue printing till end of file is reached */
    	while ( ( ch = fgetc ( fs ) ) != EOF )
    	{
    		/* if at top of page */
    		if ( top_of_page )
    		{
    			/* skip top margin */
    			for ( i = 0 ; i < tm ; i++ )
    				putc ( '\n', stdprn ) ;
    
    			top_of_page = 0 ;
    		}
    
    		putc ( ch, stdprn ) ;
    
    		/* if end of line is encountered */
    		if ( ch == '\n' )
    		{
    			row++ ;
    
    			/* if at end of page */
    			if ( row == pl - tm - bm )
    			{
    				/* skip bottom margin */
    				for ( i = 0 ; i < bm ; i++ )
    					putc ( '\n', stdprn ) ;
    
    				top_of_page = 1 ;
    				row = 1 ;
    			}
    		}
    	}
    }
    
    /* searches a string in current file */
    find()
    {
    	int esc_flag ;
    
    	/* collect the string to be searched */
    	esc_flag = ask_name ( "Enter search string", searchstr ) ;
    	if ( esc_flag )
    		return ( esc_flag ) ;
    
    	search ( searchstr ) ;
    }
    
    /* searches string and returns a pointer to it */
    char *search ( searchstr )
    char *searchstr ;
    {
    	char *p, *temp, *t_loc ;
    	int len, area, col, tr, tc, tlr, tlc ;
    
    	/* initialise temporary variables */
    	t_loc = currow ;
    	tr = curr ;
    	tc = curc ;
    	tlr = logr ;
    	tlc = logc ;
    
    	len = strlen ( searchstr ) ;
    
    	/* increment `temp' to point to character at current cursor location */
    	temp = currow ;
    	for ( col = 1 ; col < curc ; col++ )
    	{
    		if ( *temp == '\t' )
    			col += 7 ;
    
    		if ( *temp == '\n' || temp >= endloc )
    			break ;
    
    		temp++ ;
    	}
    
    	/* search string until end of file is reached or string is found */
    	while ( strncmp ( searchstr, temp, len ) != 0 )
    	{
    		/* if end of file is reached */
    		if ( temp >= endloc )
    		{
    			/* allocate memory, if unsuccessful terminate execution */
    			area = ( 17 - 8 + 1 ) * ( 60 - 19 + 1 ) * 2 ;
    			p = malloc ( area ) ;
    			if ( p == NULL )
    				error_exit() ;
    
    			/* create dialogue box */
    			savevideo ( 8, 19, 16, 60, p ) ;
    			menubox ( 8, 19, 16, 60, 112, 7 ) ;
    			drawbox ( 8, 19, 15, 58 , 112 ) ;
    
    			menubox ( 10, 21, 11, 56, 32, HALF_SHADOW ) ;
    			menubox ( 13, 21, 14, 56, 32, HALF_SHADOW ) ;
    			writestring ( "Search unsuccessful!", 10, 22, 47 ) ;
    			writestring ( "Press any key...", 13, 22, 47 ) ;
    			fflush ( stdin ) ;
    			getch() ;
    
    			/* reset the variables */
    			currow = t_loc ;
    			curr = tr ;
    			curc = tc ;
    			logr = tlr ;
    			logc = tlc ;
    
    			restorevideo ( 8, 19, 16, 60, p ) ;
    			free ( p ) ;
    			size ( 5, 7 ) ;
    			return ( 0 ) ;
    		}
    		else
    		{
    			if ( *temp == '\t' )
    			{
    				curc += 8 ;
    				temp++ ;
    			}
    			else
    			{
    				if ( *temp == '\n' )
    				{
    					/* go to beginning of next row */
    					curr++ ;
    					curc = 1 ;
    					temp++ ;
    					currow = temp ;
    				}
    				else
    				{
    					curc++ ;
    					temp++ ;
    				}
    			}
    		}
    	}
    
    	logr = 1 ;
    
    	/* position cursor at the end of search string */
    	curc += ( len - 1 ) ;
    
    	/* if the string searched lies beyond 78th column on that line */
    	if ( curc > 78 )
    	{
    		skip = curc - 78 ;
    		logc = 78 ;
    	}
    	else
    	{
    		skip = 0 ;
    		logc = curc ;
    	}
    
    	/* display the file from the line which contains the search string */
    	curscr = currow ;
    	menubox ( 2, 1, 22, 78, 27, NO_SHADOW ) ;
    	displayscreen ( curscr ) ;
    	writecol() ;
    	writerow() ;
    
    	size ( 5, 7 ) ;
    	return ( temp ) ;
    }
    
    /* searches for a string and replaces it with another string */
    replace()
    {
    	int esc_flag ;
    
    	/* collect string to be searched */
    	esc_flag = ask_name ( "Enter search string", searchstr ) ;
    	if ( esc_flag )
    		return ;
    
    	/* collect string to be substituted */
    	esc_flag = ask_name ( "Replace with", replacestr ) ;
    	if ( esc_flag )
    		return ;
    
    	f_and_r ( searchstr, replacestr ) ;
    }
    
    /* searches a string and replaces it with the specified string */
    f_and_r ( char *searchstr, char *replacestr )
    {
    	int area, ls, lr, i ;
    	char *p, *temp, *wherefr, ans ;
    
    	/* search string and set up a pointer pointing to its beginning */
    	wherefr = search ( searchstr ) ;
    
    	/* if search is unsuccessful */
    	if ( wherefr == 0 )
    		return ( 0 ) ;
    
    	/* allocate memory, if unsuccessful terminate execution */
    	area = ( 17 - 8 + 1 ) * ( 60 - 19 + 1 ) * 2 ;
    	p = malloc ( area ) ;
    	if ( p == NULL )
    		error_exit() ;
    
    	/* create dialogue box */
    	savevideo ( 8, 19, 16, 60, p ) ;
    	menubox ( 9, 19, 15, 60, 112, 7 ) ;
    	drawbox ( 9, 19, 14, 58 , 112 ) ;
    
    	menubox ( 11, 29, 12, 48, 32, HALF_SHADOW ) ;
    	writestring ( "Replace (Y/N)", 11, 30, 47 ) ;
    
    	size ( 5, 7 ) ;
    
    	/* alternate cursor between searched string and message till a key is hit */
    	while ( !kbhit() )
    	{
    		gotoxy ( 45, 12 ) ;
    		delay ( 10 ) ;
    		gotoxy ( logc + 1, logr + 2 ) ;
    		delay ( 10 ) ;
    	}
    
    	fflush ( stdin ) ;
    	ans = getch() ;
    	restorevideo ( 8, 19, 16, 60, p ) ;
    	free ( p ) ;
    
    	if ( ! ( ans == 'y' || ans == 'Y' ) )
    		return ( 0 ) ;
    
    	saved = NO ;
    
    	ls = strlen ( searchstr ) ;
    	lr = strlen ( replacestr ) ;
    
    	if ( exceed_size ( ( unsigned ) ( endloc - startloc + lr - ls ) ) )
    		return ( 1 ) ;
    
    	/* move the contents of the file after the search string to accomodate the replace string */
    	memmove ( wherefr + lr, wherefr + ls, endloc - ( wherefr + ls ) ) ;
    	endloc += ( lr - ls ) ;
    
    	/* substitute the search string with the replace string */
    	temp = wherefr ;
    	for ( i = 0 ; i < lr ; i++ )
    	{
    		*temp = replacestr[i] ;
    		temp++ ;
    	}
    
    	curc += ( lr - ls ) ;
    
    	/* if the replaced string lies beyond 78th column on that line */
    	if ( curc > 78 )
    	{
    		skip = curc - 78 ;
    		logc = 78 ;
    	}
    	else
    	{
    		skip = 0 ;
    		logc = curc ;
    	}
    
    	/* display the file from the line which contains the replaced string */
    	curscr = currow ;
    	menubox ( 2, 1, 22, 78, 27, NO_SHADOW ) ;
    	displayscreen ( curscr ) ;
    	writecol() ;
    }
    
    /* continues the last search operation */
    repeat_last()
    {
    	/* if find flag is set, search the next occurrence of the string */
    	if ( findflag )
    		search ( searchstr ) ;
    
    	/* if find and replace flag is set, search and replace the next occurrence of the string */
    	if ( frflag )
    		f_and_r ( searchstr, replacestr ) ;
    }
    
    /* abandons search operation */
    abort_find()
    {
    	frflag = 0 ;
    	findflag = 0 ;
    }
    
    /* displays file contents from specified line onwards */
    gotoline()
    {
    	char lineno[31], *temp ;
    	int number, esc_flag ;
    
    	/* collect the line number */
    	esc_flag = ask_name ( "Enter line number", lineno ) ;
    	if ( esc_flag )
    		return ;
    
    	number = atoi ( lineno ) ;
    	currow = startloc ;
    	temp = currow ;
    	curr = 2 ;
    	curc = 1 ;
    
    	/* continue till the required line is reached */
    	while ( curr != ( number + 1 ) )
    	{
    		/* if end of file is reached */
    		if ( temp >= endloc )
    			break ;
    
    		/* if end of line is reached */
    		if ( *temp == '\n' )
    		{
    			curr++ ;
    			temp++ ;
    			currow = temp ;
    		}
    		else
    			temp++ ;
    	}
    
    	/* display file contents starting from the specified line */
    	skip = 0 ;
    	curscr = currow ;
    	menubox ( 2, 1, 22, 78, 27, NO_SHADOW ) ;
    	displayscreen ( curscr ) ;
    
    	/* display current cursor position */
    	logr = 1 ;
    	logc = 1 ;
    	writerow() ;
    	writecol() ;
    
    	size ( 5, 7 ) ;
    }
    
    /* deletes character to the left of cursor */
    backspace()
    {
    	char *temp ;
    	int col ;
    
    	/* if cursor is at the first character in file */
    	if ( curc == 1 && curr == 2 )
    		return ;
    
    	/* increment `temp' to point to character at current cursor location */
    	temp = currow ;
    	for ( col = 1 ; col < curc ; col++ )
    	{
    		if ( *temp == '\t' )
    			col += 7 ;
    
    		/* if cursor is beyond the end of line */
    		if ( *temp == '\n' )
    		{
    			left() ;
    			return ;
    		}
    
    		temp++ ;
    	}
    
    	/* if the character to the left of cursor is '\n' */
    	if ( *( temp - 1 ) == '\n' )
    	{
    		/* position cursor in the previous line */
    		up_line ( 1 ) ;
    
    		/* position cursor at the end of the line */
    		end_line() ;
    
    		/* delete the '\n' at the end of the line */
    		del_char() ;
    	}
    	else
    	{
    		/* position cursor one column to the left */
    		left() ;
    
    		/* delete the character at current cursor location */
    		del_char() ;
    	}
    }
    
    /* deletes the character at current cursor position */
    del_char()
    {
    	char *temp ;
    	int col, row, count = 0 ;
    
    	/* if cursor is at end of file */
    	if ( currow >= endloc )
    		return ;
    
    	/* increment `temp' to point to character at current cursor location */
    	temp = currow ;
    	for ( col = 1 ; col < curc ; col++ )
    	{
    		if ( temp >= endloc )
    			return ;
    
    		if ( *temp == '\t' )
    			col += 7 ;
    
    		/* if cursor is beyond the end of line */
    		if ( *temp == '\n' )
    			break ;
    
    		temp++ ;
    	}
    
    	if ( temp >= endloc )
    		return ;
    
    	/* if cursor is at the end of the line or beyond the end of line */
    	if ( *temp == '\n' )
    	{
    		/* count number of spaces from end of line to current cursor position */
    		count = curc - col ;
    
    		/* rearrange buffer to move the end of line to current cursor position */
    		memmove ( temp + count, temp + 1, endloc - temp ) ;
    
    		/* put spaces from last character in the line till current cursor position */
    		memset ( temp, 32, count ) ;
    
    		endloc += ( count - 1 ) ;
    		saved = NO ;
    
    		/* display the modified line */
    		menubox ( logr + 1, 1, logr + 1, 78, 27, NO_SHADOW ) ;
    		displayline ( currow, logr + 1 ) ;
    
    		/* scroll the screen after current line */
    		scrollup ( logr + 2, 1, 22, 78 ) ;
    
    		/* display the line in the last row */
    		temp = currow ;
    		for ( row = logr + 1 ; row < 22 ; row++ )
    		{
    			/* go to the beginning of next line */
    			while ( *temp != '\n' )
    			{
    				if ( temp >= endloc )
    					return ;
    				temp++ ;
    			}
    			temp++ ;
    
    			if ( temp >= endloc )
    				return ;
    		}
    		displayline ( temp, row ) ;
    	}
    	else
    	{
    		/* rearrange buffer to delete the character */
    		memmove ( temp, temp + 1, endloc - temp ) ;
    
    		endloc-- ;
    		saved = NO ;
    
    		/* display the modified line */
    		menubox ( logr + 1, 1, logr + 1, 78, 27, NO_SHADOW ) ;
    		displayline ( currow, logr + 1 ) ;
    	}
    }
    
    /* deletes the line in which cursor is currently present */
    del_line()
    {
    	char *temp ;
    	int count = 1, row ;
    
    	/* if cursor is at end of file */
    	if ( currow == endloc )
    		return ( 0 ) ;
    
    	/* count number of characters in the line to be deleted */
    	temp = currow ;
    	while ( *temp != '\n' )
    	{
    		/* if end of file is encountered */
    		if ( temp >= endloc )
    			break ;
    
    		count++ ;
    		temp++ ;
    	}
    
    	/* if the line to be deleted is the last line and there is no Enter at the end of the line */
    	if ( temp >= endloc )
    	{
    		/* position `endloc' */
    		endloc -= count ;
    
    		/* erase last line */
    		menubox ( logr + 1, 1, logr + 1, 78, 27, NO_SHADOW ) ;
    
    		/* position cursor at the beginning of previous line */
    		up_line ( 1 ) ;
    		start_line() ;
    
    		return ( 0 ) ;
    	}
    
    	temp++ ;
    
    	/* rearrange the buffer so that current line is deleted */
    	memmove ( currow, temp, endloc - temp ) ;
    
    	endloc -= count ;
    	saved = NO ;
    
    	/* scroll the screen after current line */
    	scrollup ( logr + 1, 1, 22, 78 ) ;
    
    	/* display the line in the last row */
    	temp = currow ;
    	for ( row = logr + 1 ; row < 22 ; row++ )
    	{
    		/* go to the beginning of next line */
    		while ( *temp != '\n' )
    		{
    			if ( temp >= endloc )
    				return ( 0 ) ;
    			temp++ ;
    		}
    		temp++ ;
    
    		if ( temp >= endloc )
    			return ( 0 ) ;
    	}
    	displayline ( temp, row ) ;
    }
    
    /* deletes line to the left of current cursor position */
    del_line_lt()
    {
    	char *temp ;
    	int count, col ;
    
    	/* if cursor is at end of file */
    	if ( currow >= endloc )
    		return ;
    
    	/* count the number of characters to the left of cursor */
    	temp = currow ;
    	count = 0 ;
    	for ( col = 1 ; col < curc ; col++ )
    	{
    		if ( *temp == '\t' )
    			col += 7 ;
    
    		/* if cursor is to the right of the end of current line */
    		if ( *temp == '\n' )
    		{
    			del_line() ;  /* delete the entire line */
    			return ;
    		}
    
    		temp++ ;
    		count++ ;
    	}
    
    	/* rearrange the buffer so that line to the left of cursor is deleted */
    	memmove ( currow, temp, endloc - temp ) ;
    
    	endloc -= count ;
    	saved = NO ;
    
    	/* display the modified line */
    	menubox ( logr + 1, 1, logr + 1, 78, 27, NO_SHADOW ) ;
    	displayline ( currow, logr + 1 ) ;
    
    	/* position cursor at the beginning of the line */
    	start_line() ;
    }
    
    /* deletes line to the right of current cursor position */
    del_line_rt()
    {
    	char *temp, *temp1 ;
    	int col, count = 0 ;
    
    	/* if cursor is at end of file */
    	if ( currow >= endloc )
    		return ;
    
    	/* increment `temp' to point to character at current cursor location */
    	temp = currow ;
    	for ( col = 1 ; col < curc ; col++ )
    	{
    		if ( temp >= endloc )
    			return ;
    
    		if ( *temp == '\t' )
    			col += 7 ;
    
    		/* if cursor is to the right of the end of current line */
    		if ( *temp == '\n' )
    			return ;
    
    		temp++ ;
    	}
    
    	/* if cursor is at the end of line */
    	if ( *temp == '\n' )
    		return ;
    
    	/* count the number of characters to the right of cursor */
    	temp1 = temp ;
    	count = 0 ;
    	while ( *temp1 != '\n' )
    	{
    		if ( temp1 >= endloc )
    			break ;
    
    		temp1++ ;
    		count++ ;
    	}
    
    	/* rearrange the buffer so that line to the right of cursor is deleted */
    	memmove ( temp, temp1, endloc - temp1 ) ;
    
    	endloc -= count ;
    	saved = NO ;
    
    	/* display the modified line */
    	menubox ( logr + 1, 1, logr + 1, 78, 27, NO_SHADOW ) ;
    	displayline ( currow, logr + 1 ) ;
    }
    
    /* deletes the word to the right of current cursor position */
    del_word_rt()
    {
    	char *temp, *temp1 ;
    	int col, row, count = 0 ;
    
    	/* if cursor is at end of file */
    	if ( currow >= endloc )
    		return ;
    
    	/* increment `temp' to point to character at current cursor location */
    	temp = currow ;
    	for ( col = 1 ; col < curc ; col++ )
    	{
    		if ( temp >= endloc )
    			return ;
    
    		if ( *temp == '\t' )
    			col += 7 ;
    
    		/* if cursor is beyond the end of line */
    		if ( *temp == '\n' )
    			break ;
    
    		temp++ ;
    	}
    
    	if ( temp >= endloc )
    		return ;
    
    	/* if cursor is at the end of the line or beyond the end of line */
    	if ( *temp == '\n' )
    	{
    		/* count number of spaces from end of line to current cursor position */
    		count = curc - col ;
    
    		/* rearrange buffer to move the end of line to current cursor position */
    		memmove ( temp + count, temp + 1, endloc - temp ) ;
    
    		/* put spaces from last character in line till current cursor position */
    		memset ( temp, 32, count ) ;
    
    		endloc += ( count - 1 ) ;
    		saved = NO ;
    
    		/* display the modified line */
    		menubox ( logr + 1, 1, logr + 1, 78, 27, NO_SHADOW ) ;
    		displayline ( currow, logr + 1 ) ;
    
    		/* scroll the screen after current line */
    		scrollup ( logr + 2, 1, 22, 78 ) ;
    
    		/* display the line in the last row */
    		temp = currow ;
    		for ( row = logr + 1 ; row < 22 ; row++ )
    		{
    			/* go to the beginning of next line */
    			while ( *temp != '\n' )
    			{
    				if ( temp >= endloc )
    					return ;
    				temp++ ;
    			}
    			temp++ ;
    			if ( temp >= endloc )
    				return ;
    		}
    		displayline ( temp, row ) ;
    	}
    	else
    	{
    		temp1 = temp ;
    
    		/* if character at current cursor position is alphanumeric */
    		if ( isalnum ( *temp1 ) )
    		{
    			/* continue till a non-alphanumeric character is encountered */
    			while ( isalnum ( *temp1 ) )
    			{
    				if ( temp1 == endloc )
    					break ;
    
    				temp1++ ;
    				count++ ;
    			}
    		}
    		else
    		{
    			/* go to the next character */
    			temp1++ ;
    			count++ ;
    		}
    
    		/* skip consecutive spaces */
    		while ( *temp1 == ' ' )
    		{
    			if ( temp1 == endloc )
    				break ;
    
    			temp1++ ;
    			count++ ;
    		}
    
    		/* rearrange buffer so that word to the right of cursor is deleted */
    		memmove ( temp, temp1, endloc - temp1 ) ;
    		endloc -= count ;
    
    		/* display the modified line */
    		menubox ( logr + 1, 1, logr + 1, 78, 27, NO_SHADOW ) ;
    		displayline ( currow, logr + 1 ) ;
    	}
    }
    
    /* takes control temporarily to DOS */
    shell()
    {
    	int area, status ;
    	char *p ;
    
    	/* allocate memory, if unsuccessful terminate execution */
    	area = ( 24 - 0 + 1 ) * ( 79 - 0 + 1 ) * 2 ;
    	p = malloc ( area ) ;
    	if ( p == NULL )
    		error_exit() ;
    
    	/* create dialogue box */
    	savevideo ( 0, 0, 24, 79, p ) ;
    	menubox ( 0, 0, 24, 79, 7, NO_SHADOW ) ;
    	menubox ( 8, 21, 16, 60, 127, 47 ) ;
    
    	drawbox ( 9, 23, 14, 56, 127 ) ;
    
    	writestring ( "Quitting temporarily to DOS", 11, 25, 127 ) ;
    	writestring ( "Type EXIT to return...", 13, 25, 127 ) ;
    
    	gotoxy ( 7, 1 ) ;
    	status = system ( "C:\\COMMAND.COM" ) ;
    
    	/* if unable to load `COMMAND.COM' */
    	if ( status == -1 )
    	{
    		writestring ( "Oops! Cannot load COMMAND.COM!", 11, 25, 127 ) ;
    		writestring ( "Press any key...", 13, 25, 127 ) ;
    		fflush ( stdin ) ;
    		getch() ;
    	}
    
    	restorevideo ( 0, 0, 24, 79, p ) ;
    	free ( p ) ;
    }
    
    /* ensures that no action takes place if Ctrl - C or Ctrl - Break is hit */
    void interrupt handler()
    {
    	ctrl_c_flag = 1 ;
    }
    
    /* places a character on the screen */
    displaychar ( char ch )
    {
    	char *temp ;
    	int col = 1, insert ;
    
    	/* if current column exceeds 249, beep */
    	if ( curc >= 249 )
    	{
    		printf ( "\a" ) ;
    		return ;
    	}
    
    	/* check the status of Ins key */
    	if ( *ins & 0x80 )
    		insert = YES ;
    	else
    		insert = NO ;
    
    	/* if Enter key is hit replace it with newline */
    	if ( ch == '\r' )
    		ch = '\n' ;
    
    	/* increment `temp' to point to character at current cursor location */
    	temp = currow ;
    	for ( col = 1 ; col < curc ; col++ )
    	{
    		/* if cursor is beyond the end of line or the end of file is reached */
    		if ( *temp == '\n' || temp >= endloc )
    		{
    			/* if spacebar was hit */
    			if ( ch == ' ' )
    			{
    				/* position cursor one column to the right */
    				right() ;
    				return ;
    			}
    
    			/* if Enter key was hit */
    			if ( ch == '\n' )
    				break ;
    
    			if ( exceed_size ( ( unsigned ) ( endloc - startloc + curc - col + 1 ) ) )
    				return ;
    
    			/* rearrange buffer to move end of line to current cursor position */
    			memmove ( temp + curc - col, temp, endloc - temp ) ;
    
    			/* put spaces from last character in line till current cursor position */
    			memset ( temp, 32, curc - col ) ;
    
    			/* position `temp' at the end of these spaces */
    			temp += curc - col ;
    
    			endloc += curc - col ;
    			saved = NO ;
    
    			/* rearrange the buffer to accomodate the character hit */
    			memmove ( temp + 1, temp, endloc - temp ) ;
    
    			/* store the character in the buffer */
    			*temp = ch ;
    
    			endloc++ ;
    
    			/* display the character */
    			writechar ( logr + 1, logc, ch, 27 ) ;
    
    			/* position cursor one column to the right */
    			if ( ch == '\t' )
    			{
    				curc += 8 ;
    				logc += 8 ;
    
    				/* position cursor at appropriate column */
    				gotocol() ;
    			}
    			else
    				right() ;
    
    			return ;
    		}
    
    		if ( *temp == '\t' )
    			col += 7 ;
    
    		temp++ ;
    	}
    
    	/* if Enter key is hit */
    	if ( ch == '\n' )
    	{
    		/* if cursor is at or beyond the last character in the file */
    		if ( temp >= endloc )
    		{
    			if ( exceed_size ( ( unsigned ) ( endloc - startloc + 1 ) ) )
    				return ;
    
    			/* put the character in the buffer */
    			*temp = ch ;
    
    			endloc++ ;
    			saved = NO ;
    
    			/* erase the current line */
    			menubox ( logr + 1, logc, logr + 1, 78, 27, NO_SHADOW ) ;
    
    			/* display the modified line */
    			displayline ( currow, logr + 1 ) ;
    
    			/* position cursor at the beginning of the next line */
    			down_line ( 1 ) ;
    			start_line() ;
    			return ;
    		}
    
    		/* if Ins is off */
    		if ( insert == NO )
    		{
    			/* position cursor at the beginning of the next line */
    			down_line ( 1 ) ;
    			start_line() ;
    
    			/* position cursor on the first non-whitespace character */
    			temp = currow ;
    			while ( *temp == ' ' || *temp == '\t' )
    			{
    				if ( *temp == '\t' )
    					curc += 7 ;
    
    				temp++ ;
    				curc++ ;
    			}
    
    			/* if the first non-whitespace character is beyond the first 78 columns */
    			if ( curc > 78 )
    			{
    				/* scroll the screen horizontally */
    				logc = 78 ;
    				skip = curc - 78 ;
    				menubox ( 2, 1, 22, 78, 27, NO_SHADOW ) ;
    				displayscreen ( curscr ) ;
    			}
    			else
    				logc = curc ;
    
    			writecol() ;
    			return ;
    		}
    	}
    
    	/* if Ins is on or end of file is encountered */
    	if ( insert == YES || temp == endloc || *temp == '\n' )
    	{
    		if ( exceed_size ( ( unsigned ) ( endloc - startloc + 1 ) ) )
    			return ;
    
    		/* rearrange the buffer to accomodate the character */
    		memmove ( temp + 1, temp, endloc - temp ) ;
    
    		endloc++ ;
    	}
    
    	/* place the character in the buffer */
    	*temp = ch ;
    
    	saved = NO ;
    
    	/* if Enter is hit (Ins is on) */
    	if ( ch == '\n' )
    	{
    		/* remove spaces and tabs at the end of the line */
    		del_whitespace() ;
    
    		/* erase the current row */
    		menubox ( logr + 1, logc, logr + 1, 78, 27, NO_SHADOW ) ;
    
    		/* scroll down the screen below the current line */
    		scrolldown ( logr + 2, 1, 22, 78 ) ;
    
    		/* position cursor at the beginning of the next line */
    		down_line ( 1 ) ;
    		start_line() ;
    
    		/* display the modified current line */
    		displayline ( currow, logr + 1 ) ;
    	}
    	else
    	{
    		/* erase the current line */
    		menubox ( logr + 1, logc, logr + 1, 78, 27, NO_SHADOW ) ;
    
    		/* display the modified line */
    		displayline ( currow, logr + 1 ) ;
    
    		/* if tab key is hit */
    		if ( ch == '\t' )
    		{
    			curc += 8 ;
    			logc += 8 ;
    
    			/* position cursor at appropriate column */
    			gotocol() ;
    		}
    		else
    			right() ;  /* position cursor in the next column */
    	}
    }
    
    /* displays error message and terminates execution */
    error_exit()
    {
    	writestring ( "Memory Allocation Error! Press any key...", 22, 14, 112 ) ;
    	fflush ( stdin ) ;
    	getch() ;
    	exit ( 2 ) ;
    }
    
    /* removes spaces and tabs at the end of the line */
    del_whitespace()
    {
    	char *temp ;
    
    	/* go to the end of the line */
    	temp = currow ;
    	while ( *temp != '\n' )
    	{
    		if ( temp >= endloc )
    			return ;
    
    		temp++ ;
    	}
    
    	/* remove tabs and spaces after the end of the line */
    	while ( * ( temp - 1 ) == '\t' || * ( temp - 1 ) == ' ' )
    	{
    		memmove ( temp - 1, temp, endloc - temp ) ;
    		temp-- ;
    		endloc-- ;
    	}
    }
    
    /* checks whether the maximum buffer size is exceeded */
    exceed_size ( unsigned int size )
    {
    	int area ;
    	void *p ;
    
    	if ( size >= maxsize )
    	{
    		/* allocate memory, if unsuccessful terminate execution */
    		area = ( 14 - 11 + 1 ) * ( 64 - 15 + 1 ) * 2 ;
    		p = malloc ( area ) ;
    		if ( p == NULL )
    			error_exit() ;
    
    		/* create dialogue box */
    		savevideo ( 9, 15, 15, 65, p ) ;
    		menubox ( 9, 15, 15, 65, 112, 7 ) ;
    		drawbox ( 9, 15, 14, 63, 112 ) ;
    		writestring ( "File size too large! Delete some characters!!", 11, 17, 112 ) ;
    		writestring ( "Press any key...", 12, 17, 112 ) ;
    		getch() ;
    
    		restorevideo ( 9, 15, 15, 65, p ) ;
    		return ( 1 ) ;
    	}
    
    	return ( 0 ) ;
    }

    I m sorry for write a full code but i cant lowercase . İn this code , ill write RED line which give you to me. If you help me this subject i m so glad to you.
    Thank you .

  7. #7
    Registered User GL.Sam's Avatar
    Join Date
    Aug 2009
    Posts
    88
    Ummm... Ohhh... To say that I'm astounished means to say nothing. Would you be so kind not to do such a... thing anymore? The only thing that I can suggest is to reset file position indicator to start after the code I've provided. Sorry, I'm not going to read this monster through.
    The only good is knowledge and the only evil is ignorance.
    ~Socrates

  8. #8
    Registered User
    Join Date
    May 2010
    Posts
    5
    ) i think my code was soup youre right. Butt thank you alot for your helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21