This is a simple text editor, called CED (C EDitor) written in Borland C++ 5.0 for DOS circa 1999. It opens text files or creates new ones in the same directory as the executable. It has a limit in the rows of the text file, but you can easily extend it by changing the appropriate variable. With small text files, ie less than 200 lines, it should have no problem I suppose. Don’t expect mouse support or any GUI! It was just a small DOS program which was originally created to demonstrate string manipulation algorithms in Turbo Pascal. Thus, it provides you with actions like SEARCH string, DELETE string, INSERT string etc.
This program is the same algorithmically with TED, the text editor in Turbo Pascal section.

The program was written in Borland C++ 5.0. You will need the compiler bcc in order to compile and run it, but it’s very easy to make some alterations for other compilers or other OS’s.

 //  ed on C++   ******** CED ************
// By Makis Kalamaras  AM: 96055
 
#include <iostream .h>
#include <stdlib .h>
#include <fstream .h>
#include <conio .h>
#include <ctype .h>
#include <dos .h>
#include <bios .h>
#include <string .h>
#include <stdio .h>
 
 
 struct gram
  {
 char line[80];
  };
 gram grammi[100];
 char filename1[13], neo,flag,flag1 ,ikey;
 int i,j,k,x,y,key ;
 
void open (char flag ,char  filename1 [12] )
{
		 ifstream arxeio (filename1);
		  if (flag=='n')  ofstream arxeio (filename1);
 
			 if (flag != 'n' )
				 {
					for (i=1;i< = 24;i++)
					 {
					 arxeio.getline (grammi[i].line,80);
					 gotoxy(1,i+1);
					 cout << grammi[i].line;
                }
				 }
  }
 
void close ()
{
  gotoxy(3,25);delline();cout << "Closing File...";delay(1000);
  cout << "BYE!";delay(1000);
  clrscr();
  ofstream arxeio (filename1);
  for (i=1;i<=24;i++)
  {
  arxeio << grammi[i].line << endl;
  }
  arxeio.close();
}
 
void kelyfos(char neo)
{
				 for (i=1;i<=80;i++)
				 {
				 gotoxy(i,1);   cout << 'Í' ;
				 }
				 if (neo=='n')
				  {
					gotoxy(32,1);cout << 'µ' <<filename1 << 'Æ' ;
				  }
				 else  {    gotoxy(35,1);cout << " cEd ";    }
 
				 for (i=1;i<=79;i++)
				  {
					gotoxy(i,24);
					if (i==1)  { cout<< 'À'  ; }
					 cout << 'Ä' ;
					if (i==79) {  cout << 'Ù'  ; }
					}
				 gotoxy(3,24);  cout << "      ";
				 gotoxy(3,24);  cout <<' '<<x<<':'<<y ;
 
}
 
void refresh()
{
  clrscr();
  kelyfos('n');
  for (i=1;i<=24;i++)
	{
	gotoxy(1,i+1);
	cout << grammi[i].line;
	}
}
 
void upperall ()
{
  for (i=1;i<=24;i++)
	{
	 strupr(grammi[i].line);
	 gotoxy(1,i+1);clreol;
	 cout << grammi[i].line;
	}
}
 
 
void downall ()
{
  for (i=1;i<=24;i++)
	{
	 strlwr(grammi[i].line);
	 gotoxy(1,i+1);clreol;
	 cout << grammi[i].line;
	}
}
 
 
void seek()
{
 int fount=0,ans;
 char *pt,str [15] =" ";
 
 gotoxy(1,25);clreol();
 cout<< "Enter desired string : ";
  cin >> str ;
  refresh();
  gotoxy(3,25);
  for (i=1;i< =22;i++)
  {
	  pt=strstr(grammi[i].line,str);
 
	  if (pt)
	  {
		 fount=fount+1;
		 y=i;
		 x=pt-grammi[y].line+1;
 
		 gotoxy(1,25);delline();
		 cout << "Found a match at : ";
		 cout << x<<','<<y ;
		 gotoxy (60,25);clreol; cout << " ....continue? Y/N";
		 gotoxy(x,y+1); ans=getch();
 
		  if (ans==110||ans==78) break;
		}
 
  }
		gotoxy(1,25);clreol(); cout<< "Found " <<fount << " matches. ";
}
 
 void del()
{
 int fount=0,ans;
 char *pt,str [15] =" ",gr3[80]=" ",gr4[80]=" ";
 
 
 gotoxy(1,25);clreol();
 cout<< "Enter desired string : ";
  cin >> str ;
  refresh();
  gotoxy(3,25);
  for (i=1;i< =22;i++)
  {
	  pt=strstr(grammi[i].line,str);
 
	  if (pt)
	  {
		 fount=fount+1;
		 y=i;
		 x=pt-grammi[y].line+1;
 
		 gotoxy(1,25);delline();
		 cout << "Found a match at : ";
		 cout << x<<','<<y ;
		 gotoxy (60,25);clreol; cout << " ....delete? Y/N";
		 gotoxy(x,y+1); ans=getch();
		 if (ans==110||ans==78) break;
		 strncpy(gr3,grammi[y].line,x-1);
 
		  for (j=x+strlen(str);j<=strlen(grammi[y].line);j++)
		  {
			gr4[j-x-strlen(str)]=grammi[y].line[j-1];
		  }
		  strncat(gr3,gr4,strlen(gr4));
		  strncpy(grammi[y].line,gr3,80);
		  refresh();
		}
 
  }
		if (ans==110||ans==78)
		{
		gotoxy(1,25);clreol(); cout<< "Found " <<fount << " matches... ";
		}
		else
		{
		gotoxy(1,25);clreol(); cout<< "Deleted " <<fount << " matches. ";
		}
}
 
 
 
 void insert ()
 {
  char str1[15] ,gr[80]=" ",gr1[80]=" " ;
  int p;
  gotoxy(1,25);clreol();
  cout<< "Enter a string : ";
  cin.getline (str1,15) ;
  refresh();
  gotoxy(3,25);
  if (strlen(grammi[y].line)==0)
  { strncpy (grammi[y].line,str1,strlen(str1)); refresh();   }
  else
  {
		if (x< strlen(grammi[y].line))
		{
			strncpy (gr,grammi[y].line,x);
			strncat (gr, str1,strlen(str1));
			for  (p=0;p<strlen(grammi[y].line)-x;p++)
			{
			 gr1[p]=grammi[y].line[x+p];
			}
			strncat (gr,gr1, strlen(gr1));
			strncpy (grammi[y].line,gr,strlen(gr));
			refresh();
		}
		else
		{
		 strncat(grammi[y].line,str1,strlen(str1)); refresh();
		}
  }
 }
 
  void ins_line ()
  {
		char sym=' ';
		int i=23;
		while  (i>=y)
		{
		strset(grammi[i+1].line,sym);
		strncpy (grammi[i+1].line,grammi[i].line,strlen(grammi[i].line));
		i=i-1;
		}
		strset(grammi[y].line,sym);
		refresh();
  }
 
  void del_line ()
  {
		char sym=' ';
		int i;
		for (i=y;i< =24;i++)
		{
		strset(grammi[i].line,sym);
		strncpy (grammi[i].line,grammi[i+1].line,strlen(grammi[i+1].line));
		}
 
		refresh();
  }
 
  void line_length()
  {
	int ln;
	gotoxy(3,25);delline();
	cout << "Which Line Do You Wish To Count? ";
	cin >> ln;
	refresh();
	gotoxy(3,25);delline();
	cout < < "The Length Of Line "<< ln<< " is :"<< strlen(grammi[ln].line);
  }
 
	void comp_lines ()
	{
	int a,b,comp;
	gotoxy(3,25); delline();
	cout << "Enter line a : ";  cin>>a;refresh();
	gotoxy(3,25); delline();
	cout < < "Enter line b : ";  cin>>b;refresh();
	gotoxy (3,25);delline();
	comp=memcmp(grammi[a].line,grammi[b].line,80);
	switch (comp)  {
	case -1 : {printf(" Line [a]smaller than Line [b]");break;}
	case 0  : {printf("Lines Are Equal");break;}
	case 1  : {printf (" Line[a] greater than Line [b]");break;}
	}
 
 
	}
	void  mainmenu()
		{
		  gotoxy(3,25);
		  cout < < "CTRL + <M>enu Mode <e>dit Mode <c>ursor Mode: ";
		}
 
	 void menumode()
		  {
				kelyfos(neo);
				if (key==13 )  // CRTL +M or enter
				{
				gotoxy(3,25); delline();
				cout < <"Menu Mode: <S>earch <i>nsert <d>elete <c>ase St<r>ing <e>xit";
				flag1=' ';
				}
 
				if (key==69 || key==101)
				 {
						exit(0);
				 }
 
				if (key==83 || key==115)
				  {
					gotoxy(3,25);delline();
					cout < < "Search : S<t>ring <c>har <b>ack: ";
					flag1='s';
				  }
 
				 if (flag1=='s')
				  {
					if (key==84 ||  key==116)
					 {
					  gotoxy(3,25);delline();
					  cout < <"Search String....: ";
					  seek ();
					}
				  }
 
				 if (flag1=='s')
				  {
					if (key==67 || key==99)
					 {
					  gotoxy(3,25);delline();
					  cout <<"Search Char...: ";
					 }
				  }
 
				 if (key==68 || key==100)
					{
					 gotoxy(3,25);delline();
					 cout <<"Delete : S<t>ring <c>har <l>ine <b>ack:";
					 flag1='d';
					}
 
				 if (flag1=='d')
				  {
					if (key==84 || key==116 )
					  {
						gotoxy(3,25);delline();
						cout < <"Delete String....: ";
						del();
						}
				  }
 
				 if (flag1=='d')
				 {
					if (key==67 || key==99 )
					  {
						gotoxy(3,25);delline();
						cout << "Delete Char...: ";
		  //          del_char(x,y,1);
					  }
				  }
 
				if (flag1=='d')
				  {
					if (key==76 || key==108 )
					  {
						gotoxy(3,25);delline();
						cout << "Deleting Line...";
						del_line ();
					  }
				  }
 
				if (key==66 || key==98)
				  {
					 gotoxy(3,25);delline();
					 key=13;
					 flag1=' ';
					 menumode();
				  }
 
			 if (flag1==' ')
				 {
					if (key==67 || key==99 )
					  {
						gotoxy(3,25);delline();
						cout << "<U>ppercase D<o>wncase...: ";
						flag1=' ';
					  }
				 }
 
				if (key==85 || key==117)
				  {
					gotoxy(3,25);delline();
					cout < <" UpperCase : S<t>ring <a>ll <b>ack:";
					flag1='u';
 
				  }
 
			if (flag1=='u')
				  {
				  if (key==84 || key==116)
					  {
						gotoxy(3,25);delline();
						cout < < "Insert String to UpperCase...: ";
 
						}
					}
 
		 if (flag1=='u')
				  {
				if (key==65 || key==97)		         //uppercase ALL
					  {
						gotoxy(3,25);delline();
						cout<< "Wait... "; delay(400);
						upperall();   key=13; menumode ();
					  }
					}
 
				if (key==79 || key==111)
				  {
					gotoxy(3,25);delline();
					cout <<" DownCase : S<t>ring <a>ll <b>ack:";
					flag1='o';
 
				  }
 
				  if (key==84 || key==116)
				  {
					 if (flag1=='o')
					  {
						gotoxy(3,25);delline();
						cout < < "Insert String to DownCase...: ";
 
						}
					}
 
				if (key==65 || key==97)
				  {
					 if (flag1=='o')            // downcase all
					  {
						gotoxy(3,25);delline();
						cout<< "Wait... "; delay(400);
						downall();   key=13; menumode ();
					  }
					}
 
 
 
				if (key==73 || key==105)
				  {
					gotoxy(3,25);delline();
					cout <<"Insert : <L>ine S<t>ring <b>ack:";
					flag1='i';
				  }
 
				if (flag1=='i')
				  {
					if (key==84  || key==116)
					  {
						gotoxy(3,25);delline();
						cout< < "Insert String...: ";
						insert ();
					  }
				  }
 
				if (flag1=='i')
				  {
					if (key==76 || key==108)
					  {
						gotoxy(3,25);delline();
						cout<<"Insert line...: ";
						ins_line ();
					  }
				  }
 
					if (key==82 || key==114 )
					  {
						gotoxy(3,25);delline();
						cout <<"<L>ength <c>ompare....: ";
						flag1='r';
						}
 
 
				if (flag1=='r')
					  {
					if (key==76 || key==108)
						 {
						gotoxy(3,25);delline();
						 line_length ();
						 }
					  }
 
			 if (flag1=='r')
						{
					if (key==67 || key==99)
						  {
								gotoxy(3,25);delline();
							  comp_lines ();
							 }
					  }
		 }
 
 
	 void cursormode ()
 
			{
				 gotoxy(3,24); cout < < "      ";
				 gotoxy(3,24);  cout <<' '<<x<<':'<<y ;
				 gotoxy(3,25) ; delline();
				 cout <<" Turn NumLock [ON] Use num pad.";
 
				 if (key==56)
				  {
					if (y==1)
					{
					 gotoxy(3,24); cout << "      ";
					 gotoxy(3,24);  cout <<' '<<x<<':'<<y ;
					 gotoxy(3,25) ; delline();
					 cout <<" Turn NumLock [ON] Use num pad.";
					 y=y;
					 }
					else
					{
					 x=x;    y=y-1;
					  gotoxy(3,24); cout << "      ";
					 gotoxy(3,24);  cout <<' '<<x<<':'<<y ;
					 gotoxy(3,25) ; delline();
					 cout <<" Turn NumLock [ON] Use num pad.";
					 }
					}
 
				if (key==54)
				  {
					if (x==80)
					 {
					  x=x;
					  gotoxy(3,24); cout << "      ";
					  gotoxy(3,24);  cout <<' '<<x<<':'<<y ;
					 gotoxy(3,25) ; delline();
					 cout <<" Turn NumLock [ON] Use num pad.";
					 }
					else
					{
					  x=x+1;    y=y;
					  gotoxy(3,24); cout << "      ";
					 gotoxy(3,24);  cout <<' '<<x<<':'<<y ;
					 gotoxy(3,25) ; delline();
					 cout <<" Turn NumLock [ON] Use num pad.";
					}
				  }
 
			  if (key==52)
				  {
					if (x==1)     x=x;
					else
					{
					 x=x-1;    y=y;
					  gotoxy(3,24); cout << "      ";
					 gotoxy(3,24);  cout <<' '<<x<<':'<<y ;
					 gotoxy(3,25) ; delline();
					 cout <<" Turn NumLock [ON] Use num pad.";
					}
				  }
 
				if  (key==50)
				  {
					if (y==22) { y=y; }
					else
					 {
					  x=x;    y=y+1;
					  gotoxy(3,24); cout << "      ";
					  gotoxy(3,24);  cout <<' '<<x<<':'<<y ;
					  gotoxy(3,25) ; delline();
					  cout <<" Turn NumLock [ON] Use num pad.";
					 }
				  }
				gotoxy(x,y+1);
 
		  }
 
void main()
{
		  atexit (close);
 
		  x=1;y=1;
 
		  clrscr();
		  kelyfos(neo);
 
		  gotoxy(3,25);
		  cout << "<N>ew File <o>pen an existing file : ";
		  ikey=getche();
		  if (key=='n' || key=='N')
			 {
			 gotoxy(3,25);delline();
			 cout < < "Enter the name of the new file : ";
			 cin >> filename1;
			 flag='n';
			}
		  else
			{
			 gotoxy(3,25);delline() ;
			 cout < < " Enter the name of the existing file : ";
			 cin >> filename1;
		  }
 
		  clrscr();
 
 
				 neo='n';  kelyfos(neo) ;
				 open (flag ,filename1 );
 
 
		 gotoxy(60,25);
		 mainmenu();
			do
			 {
 
				 key=bioskey(0) %256;
 
				  if (key == 3)
					{
					 while (key!=5 && key!=13 )
						 {
						  cursormode();
						  key=bioskey(0)%256;
						 }
					 }
 
				 if (key == 13)
				  {
					while (key!=5 && key!=3)
					 {
						menumode ();
						key=bioskey(0)%256;
					 }
				  }
 
				 if (key==5)
				 {
				 gotoxy(3,25);clreol;cout < <" Edit mode: NOT YET IMPLEMENTED";
				 }
			 }
			while (key!=101 && key!=69);
 
 
}