SlideShare uma empresa Scribd logo
1 de 29
DESIGN PROBLEM
                    CSE207T
Topic:Design a text editor in linux
Submitted by:
SANJAY KUMAR CHAKRAVARTI

ROLL:A28

SEC:K2R13

REG:11006964

                                Submitted to:

                                      Mr. Sandeep Ranjan

                                      Cse dept.,LPU

                                      Phagwara,Punjab

                                       144402
ABSTRACT

Text editor is highly essential in every operating system.Without text
editor an operating system look likes ,trees without leaves.To Design
a text editor is very tough task.But I have made easy to understand.

This Design Problems gives a learning environment ,with theoretically
and practically.This Design paper contain some features,so why this
will helpful for all.The features are listed below:

   1.   Modulization of Design problems
   2.   Comment line in programme
   3.   Best approach of Algorithms provided
   4.   Best working model on file

        So,these features of text editor in this paper make different to
        all.
CONTENTS

Topic Name   Page Number
INTRODUCTION


   A text editor is used to edit plain text files. Text editors differ from word processors,
   such as Microsoft Word or WordPerfect in that they do not add additional formatting
   information to documents. You might write a paper in Word, because it contains tools
   to change fonts, margins, and layout, but Word by default puts that formatting and
   layout information directly into the file, which will confuse the compiler. If you open a
   .doc file in a text editor, you will notice that most of the file is formatting codes. Text
   editors, however, do not add formatting codes, which makes it easier to compile your
   code.
   Text editors have a feature set different from that of a traditional word processing
   program. For example most won't let you include pictures, or include tables, or
   double-space your writing. The features of text editors vary from implementation to
   implementation, but there are several kinds of features that most editors have. Below
   are listed some of the most common and useful features.

1.Creating a new file

2.Delete an existing file

3.Save a file

4.counting of charaters,words,ros,coloms and etc.

These are basic work of a text editor. An advance text editor contains many features as
following:

1.coloring

2.Font changing

3.Draw panel
PREREQUISITE
There are some prerequisite for Design a text editor as given following:

1.Knowledge of „c‟ language

2.Best knowledge of file handling

3.Linux operating
DESIGNED METHHODOLOGY
To Design a text editor a plan should must keep in mind which segments
are require at which position.First of all create all requied module using
structures or functions. In this project I have used mostly functions,
becaude it will easily understandable.There are two important steps for
writing a progrrame for text editor as following:
1.Algorithm
2.Code
Now, at first I am discussing about “algorithm” using functions.
ALGORITHM:
F1.
void passwd()
step
  1. Enter your name in “name”
  2. Enter your age in “age”
  3. Pass=rand()/10000+age+(int)name
  4. Print remember your password
  5. Enter your password in “pas”
  6. If (pas==pass) Then call show() function
     Else
     Print Invalid password try again
     Goto step 5.
  7. Stop.


void show()
step1.print “press following key as given menu:1.Menu 2.Search 3.View
4.Help” in key
Step2: if (key=1)
   Then call menu() function
     Else if (key=2)
     Then call search() function
     Else if(key=3)
     Then call view() function
     Else if(key=4)
     Then call help() function
     Else
     Print “Sorry wrong choice”
     Goto step1.
Step3: exit.


void Create()
Step1: call show() function
Step2:open an exist file fp1=fopen(“temp.txt”,”w+”)
Step3: print “Type your text and press ESCAPE to save”
Step4:while(1)
     C=getchar();
countc++;
fputc(c,fp1);
if(c==13),then
rows++;
row=rows;
else if(c==32),then
countw1++;
countw=countw1;
else if(c==8),then
countc1--;
countc=countc1;
else if(c == 27),then
close file:fclose(fp1)
Step5:call count() function
Step6:print “Enter filename ” in fn
Step7:open both file temp.txt and fn
Step8:while(!feof(fp1))
c=getc(fp1)
     putc(c,fp2)
Step9:exit
void Delete()
Step1:call function show()
Step2:Enter a file to be deleted in fn
Step3:Open the file i.e fp=fopen(fn, ”r”)
     If(fp==NULL),then
     Print “File not found
Step4:rm=remove(fn)
     If(rm==0),then
     Printf “file successfully deleted”
Step5:exit
void Display()
Step1:call show() function
Step2:Enter filename to be open in fn
Step3:open file i.e fp=fopen(fn,”r”)
     If(fp==NULL),then
     Print “file not found”
     Else
     While(!feof(fn))
     C=getc(fn)
     Print value of „c‟
Step4:exit
void search()
Step1:call function show()
Step2:Enter string to be search in str
Step3:system(grep “$str” temp.txt)
Step4:exit
void menu()
Step1:Enter you choice from list:”1.new file 2.open 3.open with editing
4.delete 0.exit” in choice
Step2:if(choice=1),then
     Call function create()
     Else If(choice==2),then
     Call function display()
     Else If(choice==3),then
     Call function append()
     Else if(choice==4),then
     Call function delete()
     Else
             Exit(0)
Step3:exit
void count()
Step1:print number of characters is “countc”
Step2:print number of words is “countw”
Step3:print numbers of rows is “row”
Step4:exit



                          CODE
     /*This text editor programme only Run and Compile with linux
     operating system*/
      #include<stdio.h>
      #include<stdlib.h>
      int i,j,ec,fg,ec2,countc=0,countw=0,row=1,col;
      char fn[20],e,c;
      FILE *fp1,*fp2,*fp;
      void name();
      void cwsh1();
      void cws();
      void show();
      void ohelp();
      void fhelp();
      void soon();
      void look();
      void Create();
      void sanjeev();
      void shubham();
      void rahul();
      void abhay();
      void sanjay();
      void Append();
      void Delete();
      void Display();
      void menu();
void passwd();
void search();
void count();
void main()
{
system("clear");
passwd();
//show();
}
void sanjeev()
{
printf("nnt");
printf("┬── ─── ─
            ─── ─── ────      ──── ─── ───
                                  ─── ─── ────         ──── ─── ───
                                                            ─── ─── ────         ──── ──
────  ──── ─── ───
           ─── ─── ────        ──── ─── ───
                                   ─── ─── ──┐n");
printf("t│ Name: SANJEE KUMAR, age:20 Years is currently study in LOVELY
PROFFESSIONAL UNIVERSITY b.tech 2nd │n");
printf("t│ year. He is a bestc and c++ programmer. His primary and secondary
education in KENDRIYA VDYALYA │n");
printf("t│ NO.-1, bokaro steel city.In class 10th he has got 78% ,In class 12th he has
got 70%.          │n");
printf("t│ you can contact with him:                                              │n");
printf("t│        Mob:7837830703                                               │n");
printf("t│        email: tunsanju@gmail.com
│n");
printf("t┴── ──── ────
              ───      ──     ──── ─── ───
                                   ─── ─── ────        ──── ─── ───
                                                            ─── ─── ────          ──── ──
────  ──── ─── ───
           ─── ─── ────        ──── ─── ───
                                   ─── ─── ───┴n");
int je;
scanf("%d",&je);
switch(je)
{
default:system("clear");
show();
break;
}
}

void search()
{
char str[20];
int ser;
printf("tt║1.Copy      ║n");
printf("tt║2.Cut      ║n");
printf("tt║3.Paste     ║n");
printf("tt║4.Back      ║n");
printf("tt╚═══════════════╝");
//printf("nnttEnter string to be searched:");
//gets(str);
scanf("%d",&ser);
switch(ser)
{
case 4:system("clear");
show();
break;
}
/*switch(ser)
{
case 1:copy();
break;
case 2:cut();
break;
case 3:paste();
break;
default:exit(0);
}*/
fp1=fopen("temp.txt","w+");
system("grep $str temp.txt");
}
void look()
{
printf("╔═══════════════╦═══════════════╦════════════
═══╦═══════════════╦═══════════════════════╦═════
═══╗n");
printf("║1.Menutt║2.Searcht║3.Viewtt║4.Helptt║5.Corporate with ust║6.Exit
║n");
printf("╚═══════════════╩═══════════════╩════════════
═══╩═══════════════╩═══════════════════════╩═════
═══╝n");
}
void help()
{
int he;
printf("tttttt");
printf("│ 1.Online Help │n");
printf("tttttt│ 2.Offline Help │n");
printf("tttttt│ 3.Back      │n");
printf("tttttt└──── ────  ──── ─┴n");
                                     ───
scanf("%d",&he);
switch(he)
{
case 1:system("clear");
look();
ohelp();
break;
case 2:system("clear");
look();
fhelp();
break;
default:system("clear");
show();
break;
}
}
void show()
{
int key;
look();
scanf("%d",&key);
system("clear");
look();
switch(key)
{
case 1:menu();
break;
case 2:search();
break;
case 3:view();
break;
case 4:help();
break;
case 5:cwsh();
break;
case 6:exit(0);
//break;
}
}
void cwsh1()
{
printf("ttttttt│ 1.MANUAL         │n");
printf("ttttttt│ 2.NAME         │n");
printf("ttttttt│ 3.Back       │n");
printf("ttttttt└─ ────
                         ──      ──── ───
                                     ─── ──┴n");
}
void name()
{
int nam;
printf("n");
printf("tttttttt");
printf("│ 1.Manual│n");
printf("tttttttt│ 2.NAME │■│ 1.SANJEEV │n");
printf("tttttttt│ 3.Back │ │ 2.SHUBHAM │n");
printf("tttttttt└─  ──────── 3.ABHAY
                                     ┴│              │n");
printf("tttttttt       │ 4.RAHUL      │n");
printf("tttttttt       └── ──── ─── ┴n");
                                   ───      ─── ─
scanf("%d",&nam);
switch(nam)
{
case 1:system("clear");
look();
sanjeev();
break;
case 2:system("clear");
look();
//shubham();
break;
case 3:system("clear");
look();
//abhay();
break;
case 4:system("clear");
look();
//rahul();
break;
default:system("clear");
show();
break;
}
}
void cwsh()
{
int cw;
cwsh1();
scanf("%d",&cw);
switch(cw)
{
case 1:system("clear");
look();
cws();
break;
case 2:system("clear");
look();
//cwsh1();
name();
break;
default:system("clear");
show();
break;
}
}
void cws()
{
system("clear");
look();
printf("nnTHIS PROGRAMME IS CREATED BY:SANJAY KUMAR CHAKRAVARTIn");
printf("nttttREG:11006964nnn");
printf("nApart from the efforts of me, the success of this project depends largely on
the encouragement and ");
printf("guidelines of many others. I take this opportunity to express my gratitude to
the people who have been");
printf(" instrumental in the successful completion of this project." );
printf("I would like to show my greatest appreciation to Mr. Sandeep ranjan. I can’t say
thank you enough for his");
printf(" tremendous support and help. I feel motivated and encouraged every time I
attend his Extra classes.");
printf(" Without his encouragement and guidance this project would not have
materialized.");

printf("The guidance and support received from all the team members including
n1.SANJEEV KUMAR(LPU)n2.SHUBHAM PATEL(LPU)n3.ABHAY ");
printf("KUMAR(LPU)n4.RAHUL TEHLANI(LPU)n who contributed and are contributing
to this project, was vital for the success of the");
 printf("project. I am grateful for their constant support and help.nn");
}
void ohelp()
{
int fl;
printf("nn");
printf("┬── ─── ─
             ─── ─── ────       ──── ─── ───
                                     ─── ─── ────       ──── ─── ───
                                                             ─── ─── ────          ──────
────   ──── ─── ───
           ─── ─── ┐n");
printf("│                                                │n");
printf("│Please go on following link:                                │n");
printf("│ 1.www.gnu.com                                           │n");
printf("│ 2.www.cpluplusprogramming.com                                     │n");
printf("│ 3.www.cprogramming.com                                         │n");
printf("│ 4.www.deniweb.com                                          │n");
printf("│ 5.www.math-linux.com/IMG/pdf/Linuxbible.com                              │n");
printf("│ 6.www.ibblio.org/pub/linux/docs/HOWTO-other-formats/pdf/Linux-Init-
HOWTO.pdf │n");
printf("└─ ──── ──
           ───      ─── ────    ──── ─── ───
                                      ─── ─── ────          ──── ─── ───
                                                                 ─── ─── ────        ──── ─
────  ──── ─── ───
           ─── ─── ┴n");
scanf("%d",&fl);
switch(fl)
{
default:system("clear");
show();
break;
}
}
void fhelp()
{
printf("nn");
printf("┬── ─── ─
             ─── ─── ────      ──── ─── ───
                                     ─── ─── ────          ──── ─── ───
                                                                ─── ─── ────        ──── ──
────  ──── ─── ───
           ─── ─── ────         ──── ─── ───
                                      ─── ─── ────          ──── ┐n");
printf("│A text editor is used to edit plain text files. Text editors differ from word
processors, such as Microsoft │n");
printf("│Word or WordPerfect in that they do not add additional formatting
information to documents. You might write │n"); printf("│a paper in Word, because
it contains tools to change fonts, margins, and layout, but Word by default          │n");
printf("│puts that formatting and layout information directly into the file, which will
confuse the compiler. If │n");
printf("│you open a .doc file in a text editor, you will notice that most of the file is
formatting codes. Text │n");
printf("│editors, however, do not add formatting codes, which makes it easier to
compile your code.              │n");
printf("│Text editors have a feature set different from that of atraditional word
processing program. For example │n");
printf("│most won't let you include pictures, or include tables, or double- space your
writing. The features of      │n");
printf("│text editors vary from implementation to implementation, but there are
several kinds of features that most │n");
printf("│editors have. Below are listed some of the most common and useful features.
│n");
printf("└─ ──── ──
           ───      ─── ────    ──── ─── ───
                                      ─── ─── ────          ──── ─── ───
                                                                 ─── ─── ────        ──── ─
────  ──── ─── ───
           ─── ─── ────         ──── ─── ───
                                      ─── ─── ────          ──── ┴n");
printf("│ 1.Creating a new file                 │n");
printf("│ 2.Delete an existing file             │n");
printf("│ 3.Save a file                     │n");
printf("│ 4.counting of charaters,words,ros,coloms and etc.│n");
printf("└─ ──── ──
           ───      ─── ────    ──── ─── ───
                                      ─── ─── ────       ──── ───
                                                              ─── ───┴n");
printf("These are basic work of a text editor. An advance text editor contains many
features as following:n");
printf("┬── ─── ─
             ─── ─── ────     ────   ─┐n");
printf("│ 1.coloring      │n");
printf("│ 2.Font changing │n");
printf("│ 3.Draw panel      │n");
printf("└─ ──── ──
           ───      ─── ────    ────  ┴n");
}
void soon()
{
int so;
printf("nnntt┬─ ────
                       ───     ──── ─── ───
                                     ─── ─── ────        ──── ─┐n");
                                                              ───
printf("tt│                      │n");
printf("tt│ This module is under construction │n");
printf("tt│ 0.Return                 │n");
printf("tt└── ─── ────
                ─── ──         ──── ─── ───
                                     ─── ─── ────        ──┴n");
scanf("%d",&so);
switch(so)
{
default:system("clear");
show();
break;
}
}
void view()
{
//printf("nttttt1.Largenttttt2.Smallnttttt3.Mediumn");
printf("tttt║1.Large     ║n");
printf("tttt║2.Small     ║n");
printf("tttt║3.Medium       ║n");
printf("tttt║4.Back      ║n");
printf("tttt╚═══════════════╝n");
int vi;
scanf("%d",&vi);
switch(vi)
{
case 1:system("clear");
look();
soon();
break;
case 2:system("clear");
look();
soon();
break;
case 3:system("clear");
look();
soon();
break;
case 4:system("clear");
show();
break;
}
}
void count()
{
printf("nTotal:nnt");
printf("Characters:%d",countc);
printf("ntwords:%d",countw);
printf("ntRows:%d",row);
col=countc+countw;
if(col>=70)
{
col=0;
}
else
{
printf("ntColums:%d",col);
}
}
void passwd()
{
char name[28];
int age;
int pass;
int pas;
int ent;
pass1:
printf("nnnnEnter your name:");
gets(name);
printf("nEnter you age:");
scanf("%d",&age);
pass=rand()/100000+age+((int)name)/10000;
printf("nnnYou password is:%d",pass);
printf("nPlease remember you password");
pass2:
printf("nnnnttEnter your password:");
scanf("%d",&pas);
system("clear");
if(pas==pass)
{
show();
//menu();
}
else
{
system("clear");
printf("nnnttWrong passwordn");
printf("nPress desire key:n");
printf("n1.Re-generate your password:");
printf("n2.Re-enter you password");
printf("n0.Exitn");
scanf("%d",&ent);
switch(ent)
{
case 1:
goto pass1;
break;
case 2:
goto pass2;
break;
case 0:
exit(0);
}
}
}
void menu()
{
do
{
//printf("╔════════════╗n");
printf("║1.New File ║n");
printf("║2.Open     ║n");
printf("║3.Edit    ║n");
printf("║4.Delete ║n");
printf("║5.Back    ║n");
printf("╚══════════════╝n");
scanf("%d",&ec);
switch(ec)
{
case 1:
Create();
break;
case 2:
Display();
break;
case 3:
Append();
break;
case 4:
Delete();
break;
case 5:system("clear");
show();
break;
}
}while(1);
}
void Create()
{
system("clear");
show();
int countw1=1,rows=1,countc1=0;
fp1=fopen("temp.txt","w+");
printf("ntEnter the text and press Esc to savennt");
while(1)
{
c=getchar();
countc++;
fputc(c,fp1);
if(c==13)
{
rows=rows+1;
row=rows;
}
else if(c==32)
{
countw1++;
countw=countw1;
}
else if(c==8)
{
countc1=countc1-1;
countc=countc1;
}
else if(c == 27)
{
fclose(fp1);
count();
ff:
printf("ntEnter then new filename: ");
scanf("%s",fn);
if(fn=="."||fn=="?"||fn=="/"||fn=="!"||fn=="@"||fn=="#"||fn=="$"||fn=="%"||fn==
"^"||fn=="&"||fn=="*"||fn=="(")
{
printf("nnnnntttBad File format try againn");
goto ff;
}
else
{
fp1=fopen("temp.txt","r");
fp2=fopen(fn,"w");
while(!feof(fp1))
{
c=getc(fp1);
putc(c,fp2);
}
fclose(fp2);
system("clear");
show();
}}
}}
void Display()
{
//show();
printf("ntEnter the file name: ");
scanf("%s",fn);
fp1=fopen(fn,"r");
if(fp1==NULL)
{
printf("ntFile not found!");
int fn;
scanf("%d",&fn);
switch(fn)
{
default:system("clear");
show();
}
}
system("clear");
look();
while(!feof(fp1))
{
c=getc(fp1);
printf("%c",c);
}
int del;
scanf("%d",&del);
switch(del)
{
default:system("clear");
show();
}
end1:
fclose(fp1);
//menu();
//system("clear");
//printf("n");
//show();
}
void Delete()
{
system("clear");
look();
printf("ntEnter the file name: ");
scanf("%s",fn);
fp1=fopen(fn,"r");
if(fp1==NULL)
{
system("clear");
look();
printf("ntFile not found!n");
int ff;
scanf("%d",&ff);
switch(ff)
{

default:system("clear");
show();
}
}
fclose(fp1);
if(remove(fn)==0)
{
printf("nntFile has been deleted successfully!");
int de;
scanf("%d",&de);
switch(de)
{
default:system("clear");
show();
break;
}
}
else
system("clear");
look();
printf("ntError!n");
show();
}

void Append()
{
system("clear");
look();
printf("ntEnter the file name: ");
scanf("%s",fn);
fp1=fopen(fn,"r");
if(fp1==NULL)
{
system("clear");
look();
printf("ntFile not found!");
int nu;
scanf("%d",&nu);
switch(nu)
{
default:system("clear");
show();
}
goto end3;
}
while(!feof(fp1))
{
c=getc(fp1);
printf("%c",c);
}
fclose(fp1);
printf("ntType the text and press ESCAPE to append.n");
fp1=fopen(fn,"a");
while(1)
{
c=getchar();
//if(c==19)
//goto end3;
if(c==13)
{
c='n';
printf("nt");
fputc(c,fp1);
}
else if(c==27)
{
system("clear");
show();
}
else
{
printf("%c",c);
fputc(c,fp1);
}
}
end3: fclose(fp1);
system("clear");
 menu();
}
SAMPLE INPUTS

This programme will take some inputs for working with a file.
Some inputs:
Name:sanjay kumar chakravarti
Age:20




Selection of menu:
Design problem

Mais conteúdo relacionado

Mais procurados

The best unix shell scripting interview questions 2018 learn now!
The best unix shell scripting interview questions 2018   learn now!The best unix shell scripting interview questions 2018   learn now!
The best unix shell scripting interview questions 2018 learn now!mia avery
 
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip CalçadoJustjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip CalçadoPaulo Silveira
 
Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)Benjamin Bock
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string libraryMomenMostafa
 
A Slipshod Check of the Visual C++ 2013 Library (update 3)
A Slipshod Check of the Visual C++ 2013 Library (update 3)A Slipshod Check of the Visual C++ 2013 Library (update 3)
A Slipshod Check of the Visual C++ 2013 Library (update 3)Andrey Karpov
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumlercorehard_by
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumpingMomenMostafa
 
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 AttributesEmpty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 AttributesBartlomiej Filipek
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointersMomenMostafa
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsPVS-Studio
 
Building resilient services in go
Building resilient services in goBuilding resilient services in go
Building resilient services in goJaehue Jang
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...ssuserd6b1fd
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - english2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - englishJen Yee Hong
 
Haxe by sergei egorov
Haxe by sergei egorovHaxe by sergei egorov
Haxe by sergei egorovSergei Egorov
 
Final requirement in programming niperos
Final requirement in programming   niperosFinal requirement in programming   niperos
Final requirement in programming niperosmarkings17
 
To GO or not to GO
To GO or not to GOTo GO or not to GO
To GO or not to GOsuperstas88
 
Tensor comprehensions
Tensor comprehensionsTensor comprehensions
Tensor comprehensionsMr. Vengineer
 

Mais procurados (20)

The best unix shell scripting interview questions 2018 learn now!
The best unix shell scripting interview questions 2018   learn now!The best unix shell scripting interview questions 2018   learn now!
The best unix shell scripting interview questions 2018 learn now!
 
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip CalçadoJustjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
Justjava 2007 Arquitetura Java EE Paulo Silveira, Phillip Calçado
 
7 functions
7  functions7  functions
7 functions
 
Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
 
A Slipshod Check of the Visual C++ 2013 Library (update 3)
A Slipshod Check of the Visual C++ 2013 Library (update 3)A Slipshod Check of the Visual C++ 2013 Library (update 3)
A Slipshod Check of the Visual C++ 2013 Library (update 3)
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumler
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
 
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 AttributesEmpty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
Empty Base Class Optimisation, [[no_unique_address]] and other C++20 Attributes
 
2 data and c
2 data and c2 data and c
2 data and c
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code Contracts
 
Building resilient services in go
Building resilient services in goBuilding resilient services in go
Building resilient services in go
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - english2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - english
 
Haxe by sergei egorov
Haxe by sergei egorovHaxe by sergei egorov
Haxe by sergei egorov
 
Final requirement in programming niperos
Final requirement in programming   niperosFinal requirement in programming   niperos
Final requirement in programming niperos
 
To GO or not to GO
To GO or not to GOTo GO or not to GO
To GO or not to GO
 
Tensor comprehensions
Tensor comprehensionsTensor comprehensions
Tensor comprehensions
 

Semelhante a Design problem

Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in cgkgaur1987
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
systems programming lab programs in c
systems programming lab programs in csystems programming lab programs in c
systems programming lab programs in cMeghna Roy
 
Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9alish sha
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxCOMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxdonnajames55
 
Text editors project
Text editors projectText editors project
Text editors projectMohit kumar
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)Sami Said
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10alish sha
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisFastly
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programmingYanchang Zhao
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers ToolboxStefan
 

Semelhante a Design problem (20)

Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
2 debugging-c
2 debugging-c2 debugging-c
2 debugging-c
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
systems programming lab programs in c
systems programming lab programs in csystems programming lab programs in c
systems programming lab programs in c
 
Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxCOMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
 
Text editors project
Text editors projectText editors project
Text editors project
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programming
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
Cc code cards
Cc code cardsCc code cards
Cc code cards
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 

Mais de Sanjay Kumar Chakravarti

Mais de Sanjay Kumar Chakravarti (8)

IMPLEMENTATION OF AUTO KEY IN C++
IMPLEMENTATION OF AUTO KEY IN C++IMPLEMENTATION OF AUTO KEY IN C++
IMPLEMENTATION OF AUTO KEY IN C++
 
Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.
 
Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.
 
Microassembler a10
Microassembler a10Microassembler a10
Microassembler a10
 
Micro Assembler
Micro AssemblerMicro Assembler
Micro Assembler
 
Graphical representation of Stack
Graphical representation of StackGraphical representation of Stack
Graphical representation of Stack
 
Computer Network
Computer NetworkComputer Network
Computer Network
 
Structured Analysis and Structured Design
Structured Analysis and Structured DesignStructured Analysis and Structured Design
Structured Analysis and Structured Design
 

Design problem

  • 1. DESIGN PROBLEM CSE207T Topic:Design a text editor in linux Submitted by: SANJAY KUMAR CHAKRAVARTI ROLL:A28 SEC:K2R13 REG:11006964 Submitted to: Mr. Sandeep Ranjan Cse dept.,LPU Phagwara,Punjab 144402
  • 2. ABSTRACT Text editor is highly essential in every operating system.Without text editor an operating system look likes ,trees without leaves.To Design a text editor is very tough task.But I have made easy to understand. This Design Problems gives a learning environment ,with theoretically and practically.This Design paper contain some features,so why this will helpful for all.The features are listed below: 1. Modulization of Design problems 2. Comment line in programme 3. Best approach of Algorithms provided 4. Best working model on file So,these features of text editor in this paper make different to all.
  • 3. CONTENTS Topic Name Page Number
  • 4. INTRODUCTION A text editor is used to edit plain text files. Text editors differ from word processors, such as Microsoft Word or WordPerfect in that they do not add additional formatting information to documents. You might write a paper in Word, because it contains tools to change fonts, margins, and layout, but Word by default puts that formatting and layout information directly into the file, which will confuse the compiler. If you open a .doc file in a text editor, you will notice that most of the file is formatting codes. Text editors, however, do not add formatting codes, which makes it easier to compile your code. Text editors have a feature set different from that of a traditional word processing program. For example most won't let you include pictures, or include tables, or double-space your writing. The features of text editors vary from implementation to implementation, but there are several kinds of features that most editors have. Below are listed some of the most common and useful features. 1.Creating a new file 2.Delete an existing file 3.Save a file 4.counting of charaters,words,ros,coloms and etc. These are basic work of a text editor. An advance text editor contains many features as following: 1.coloring 2.Font changing 3.Draw panel
  • 5. PREREQUISITE There are some prerequisite for Design a text editor as given following: 1.Knowledge of „c‟ language 2.Best knowledge of file handling 3.Linux operating
  • 6. DESIGNED METHHODOLOGY To Design a text editor a plan should must keep in mind which segments are require at which position.First of all create all requied module using structures or functions. In this project I have used mostly functions, becaude it will easily understandable.There are two important steps for writing a progrrame for text editor as following: 1.Algorithm 2.Code Now, at first I am discussing about “algorithm” using functions. ALGORITHM: F1. void passwd() step 1. Enter your name in “name” 2. Enter your age in “age” 3. Pass=rand()/10000+age+(int)name 4. Print remember your password 5. Enter your password in “pas” 6. If (pas==pass) Then call show() function Else Print Invalid password try again Goto step 5. 7. Stop. void show()
  • 7. step1.print “press following key as given menu:1.Menu 2.Search 3.View 4.Help” in key Step2: if (key=1) Then call menu() function Else if (key=2) Then call search() function Else if(key=3) Then call view() function Else if(key=4) Then call help() function Else Print “Sorry wrong choice” Goto step1. Step3: exit. void Create() Step1: call show() function Step2:open an exist file fp1=fopen(“temp.txt”,”w+”) Step3: print “Type your text and press ESCAPE to save” Step4:while(1) C=getchar();
  • 8. countc++; fputc(c,fp1); if(c==13),then rows++; row=rows; else if(c==32),then countw1++; countw=countw1; else if(c==8),then countc1--; countc=countc1; else if(c == 27),then close file:fclose(fp1) Step5:call count() function Step6:print “Enter filename ” in fn Step7:open both file temp.txt and fn Step8:while(!feof(fp1)) c=getc(fp1) putc(c,fp2) Step9:exit
  • 9. void Delete() Step1:call function show() Step2:Enter a file to be deleted in fn Step3:Open the file i.e fp=fopen(fn, ”r”) If(fp==NULL),then Print “File not found Step4:rm=remove(fn) If(rm==0),then Printf “file successfully deleted” Step5:exit void Display() Step1:call show() function Step2:Enter filename to be open in fn Step3:open file i.e fp=fopen(fn,”r”) If(fp==NULL),then Print “file not found” Else While(!feof(fn)) C=getc(fn) Print value of „c‟ Step4:exit
  • 10. void search() Step1:call function show() Step2:Enter string to be search in str Step3:system(grep “$str” temp.txt) Step4:exit void menu() Step1:Enter you choice from list:”1.new file 2.open 3.open with editing 4.delete 0.exit” in choice Step2:if(choice=1),then Call function create() Else If(choice==2),then Call function display() Else If(choice==3),then Call function append() Else if(choice==4),then Call function delete() Else Exit(0) Step3:exit
  • 11. void count() Step1:print number of characters is “countc” Step2:print number of words is “countw” Step3:print numbers of rows is “row” Step4:exit CODE /*This text editor programme only Run and Compile with linux operating system*/ #include<stdio.h> #include<stdlib.h> int i,j,ec,fg,ec2,countc=0,countw=0,row=1,col; char fn[20],e,c; FILE *fp1,*fp2,*fp; void name(); void cwsh1(); void cws(); void show(); void ohelp(); void fhelp(); void soon(); void look(); void Create(); void sanjeev(); void shubham(); void rahul(); void abhay(); void sanjay(); void Append(); void Delete(); void Display(); void menu();
  • 12. void passwd(); void search(); void count(); void main() { system("clear"); passwd(); //show(); } void sanjeev() { printf("nnt"); printf("┬── ─── ─ ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ── ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ──┐n"); printf("t│ Name: SANJEE KUMAR, age:20 Years is currently study in LOVELY PROFFESSIONAL UNIVERSITY b.tech 2nd │n"); printf("t│ year. He is a bestc and c++ programmer. His primary and secondary education in KENDRIYA VDYALYA │n"); printf("t│ NO.-1, bokaro steel city.In class 10th he has got 78% ,In class 12th he has got 70%. │n"); printf("t│ you can contact with him: │n"); printf("t│ Mob:7837830703 │n"); printf("t│ email: tunsanju@gmail.com │n"); printf("t┴── ──── ──── ─── ── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ── ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ───┴n"); int je; scanf("%d",&je); switch(je) { default:system("clear"); show(); break; } } void search() {
  • 13. char str[20]; int ser; printf("tt║1.Copy ║n"); printf("tt║2.Cut ║n"); printf("tt║3.Paste ║n"); printf("tt║4.Back ║n"); printf("tt╚═══════════════╝"); //printf("nnttEnter string to be searched:"); //gets(str); scanf("%d",&ser); switch(ser) { case 4:system("clear"); show(); break; } /*switch(ser) { case 1:copy(); break; case 2:cut(); break; case 3:paste(); break; default:exit(0); }*/ fp1=fopen("temp.txt","w+"); system("grep $str temp.txt"); } void look() { printf("╔═══════════════╦═══════════════╦════════════ ═══╦═══════════════╦═══════════════════════╦═════ ═══╗n"); printf("║1.Menutt║2.Searcht║3.Viewtt║4.Helptt║5.Corporate with ust║6.Exit ║n");
  • 14. printf("╚═══════════════╩═══════════════╩════════════ ═══╩═══════════════╩═══════════════════════╩═════ ═══╝n"); } void help() { int he; printf("tttttt"); printf("│ 1.Online Help │n"); printf("tttttt│ 2.Offline Help │n"); printf("tttttt│ 3.Back │n"); printf("tttttt└──── ──── ──── ─┴n"); ─── scanf("%d",&he); switch(he) { case 1:system("clear"); look(); ohelp(); break; case 2:system("clear"); look(); fhelp(); break; default:system("clear"); show(); break; } } void show() { int key; look(); scanf("%d",&key); system("clear"); look(); switch(key) { case 1:menu();
  • 15. break; case 2:search(); break; case 3:view(); break; case 4:help(); break; case 5:cwsh(); break; case 6:exit(0); //break; } } void cwsh1() { printf("ttttttt│ 1.MANUAL │n"); printf("ttttttt│ 2.NAME │n"); printf("ttttttt│ 3.Back │n"); printf("ttttttt└─ ──── ── ──── ─── ─── ──┴n"); } void name() { int nam; printf("n"); printf("tttttttt"); printf("│ 1.Manual│n"); printf("tttttttt│ 2.NAME │■│ 1.SANJEEV │n"); printf("tttttttt│ 3.Back │ │ 2.SHUBHAM │n"); printf("tttttttt└─ ──────── 3.ABHAY ┴│ │n"); printf("tttttttt │ 4.RAHUL │n"); printf("tttttttt └── ──── ─── ┴n"); ─── ─── ─ scanf("%d",&nam); switch(nam) { case 1:system("clear"); look(); sanjeev(); break;
  • 16. case 2:system("clear"); look(); //shubham(); break; case 3:system("clear"); look(); //abhay(); break; case 4:system("clear"); look(); //rahul(); break; default:system("clear"); show(); break; } } void cwsh() { int cw; cwsh1(); scanf("%d",&cw); switch(cw) { case 1:system("clear"); look(); cws(); break; case 2:system("clear"); look(); //cwsh1(); name(); break; default:system("clear"); show(); break; } }
  • 17. void cws() { system("clear"); look(); printf("nnTHIS PROGRAMME IS CREATED BY:SANJAY KUMAR CHAKRAVARTIn"); printf("nttttREG:11006964nnn"); printf("nApart from the efforts of me, the success of this project depends largely on the encouragement and "); printf("guidelines of many others. I take this opportunity to express my gratitude to the people who have been"); printf(" instrumental in the successful completion of this project." ); printf("I would like to show my greatest appreciation to Mr. Sandeep ranjan. I can’t say thank you enough for his"); printf(" tremendous support and help. I feel motivated and encouraged every time I attend his Extra classes."); printf(" Without his encouragement and guidance this project would not have materialized."); printf("The guidance and support received from all the team members including n1.SANJEEV KUMAR(LPU)n2.SHUBHAM PATEL(LPU)n3.ABHAY "); printf("KUMAR(LPU)n4.RAHUL TEHLANI(LPU)n who contributed and are contributing to this project, was vital for the success of the"); printf("project. I am grateful for their constant support and help.nn"); } void ohelp() { int fl; printf("nn"); printf("┬── ─── ─ ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ──── ────── ──── ──── ─── ─── ─── ─── ┐n"); printf("│ │n"); printf("│Please go on following link: │n"); printf("│ 1.www.gnu.com │n"); printf("│ 2.www.cpluplusprogramming.com │n"); printf("│ 3.www.cprogramming.com │n"); printf("│ 4.www.deniweb.com │n"); printf("│ 5.www.math-linux.com/IMG/pdf/Linuxbible.com │n");
  • 18. printf("│ 6.www.ibblio.org/pub/linux/docs/HOWTO-other-formats/pdf/Linux-Init- HOWTO.pdf │n"); printf("└─ ──── ── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ─ ──── ──── ─── ─── ─── ─── ┴n"); scanf("%d",&fl); switch(fl) { default:system("clear"); show(); break; } } void fhelp() { printf("nn"); printf("┬── ─── ─ ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ── ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ┐n"); printf("│A text editor is used to edit plain text files. Text editors differ from word processors, such as Microsoft │n"); printf("│Word or WordPerfect in that they do not add additional formatting information to documents. You might write │n"); printf("│a paper in Word, because it contains tools to change fonts, margins, and layout, but Word by default │n"); printf("│puts that formatting and layout information directly into the file, which will confuse the compiler. If │n"); printf("│you open a .doc file in a text editor, you will notice that most of the file is formatting codes. Text │n"); printf("│editors, however, do not add formatting codes, which makes it easier to compile your code. │n"); printf("│Text editors have a feature set different from that of atraditional word processing program. For example │n"); printf("│most won't let you include pictures, or include tables, or double- space your writing. The features of │n"); printf("│text editors vary from implementation to implementation, but there are several kinds of features that most │n"); printf("│editors have. Below are listed some of the most common and useful features. │n"); printf("└─ ──── ── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ─ ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ┴n");
  • 19. printf("│ 1.Creating a new file │n"); printf("│ 2.Delete an existing file │n"); printf("│ 3.Save a file │n"); printf("│ 4.counting of charaters,words,ros,coloms and etc.│n"); printf("└─ ──── ── ─── ─── ──── ──── ─── ─── ─── ─── ──── ──── ─── ─── ───┴n"); printf("These are basic work of a text editor. An advance text editor contains many features as following:n"); printf("┬── ─── ─ ─── ─── ──── ──── ─┐n"); printf("│ 1.coloring │n"); printf("│ 2.Font changing │n"); printf("│ 3.Draw panel │n"); printf("└─ ──── ── ─── ─── ──── ──── ┴n"); } void soon() { int so; printf("nnntt┬─ ──── ─── ──── ─── ─── ─── ─── ──── ──── ─┐n"); ─── printf("tt│ │n"); printf("tt│ This module is under construction │n"); printf("tt│ 0.Return │n"); printf("tt└── ─── ──── ─── ── ──── ─── ─── ─── ─── ──── ──┴n"); scanf("%d",&so); switch(so) { default:system("clear"); show(); break; } } void view() { //printf("nttttt1.Largenttttt2.Smallnttttt3.Mediumn"); printf("tttt║1.Large ║n"); printf("tttt║2.Small ║n"); printf("tttt║3.Medium ║n"); printf("tttt║4.Back ║n"); printf("tttt╚═══════════════╝n"); int vi;
  • 20. scanf("%d",&vi); switch(vi) { case 1:system("clear"); look(); soon(); break; case 2:system("clear"); look(); soon(); break; case 3:system("clear"); look(); soon(); break; case 4:system("clear"); show(); break; } } void count() { printf("nTotal:nnt"); printf("Characters:%d",countc); printf("ntwords:%d",countw); printf("ntRows:%d",row); col=countc+countw; if(col>=70) { col=0; } else { printf("ntColums:%d",col); } } void passwd() {
  • 21. char name[28]; int age; int pass; int pas; int ent; pass1: printf("nnnnEnter your name:"); gets(name); printf("nEnter you age:"); scanf("%d",&age); pass=rand()/100000+age+((int)name)/10000; printf("nnnYou password is:%d",pass); printf("nPlease remember you password"); pass2: printf("nnnnttEnter your password:"); scanf("%d",&pas); system("clear"); if(pas==pass) { show(); //menu(); } else { system("clear"); printf("nnnttWrong passwordn"); printf("nPress desire key:n"); printf("n1.Re-generate your password:"); printf("n2.Re-enter you password"); printf("n0.Exitn"); scanf("%d",&ent); switch(ent) { case 1: goto pass1; break; case 2: goto pass2;
  • 22. break; case 0: exit(0); } } } void menu() { do { //printf("╔════════════╗n"); printf("║1.New File ║n"); printf("║2.Open ║n"); printf("║3.Edit ║n"); printf("║4.Delete ║n"); printf("║5.Back ║n"); printf("╚══════════════╝n"); scanf("%d",&ec); switch(ec) { case 1: Create(); break; case 2: Display(); break; case 3: Append(); break; case 4: Delete(); break; case 5:system("clear"); show(); break; } }while(1);
  • 23. } void Create() { system("clear"); show(); int countw1=1,rows=1,countc1=0; fp1=fopen("temp.txt","w+"); printf("ntEnter the text and press Esc to savennt"); while(1) { c=getchar(); countc++; fputc(c,fp1); if(c==13) { rows=rows+1; row=rows; } else if(c==32) { countw1++; countw=countw1; } else if(c==8) { countc1=countc1-1; countc=countc1; } else if(c == 27) { fclose(fp1); count(); ff: printf("ntEnter then new filename: "); scanf("%s",fn); if(fn=="."||fn=="?"||fn=="/"||fn=="!"||fn=="@"||fn=="#"||fn=="$"||fn=="%"||fn== "^"||fn=="&"||fn=="*"||fn=="(") {
  • 24. printf("nnnnntttBad File format try againn"); goto ff; } else { fp1=fopen("temp.txt","r"); fp2=fopen(fn,"w"); while(!feof(fp1)) { c=getc(fp1); putc(c,fp2); } fclose(fp2); system("clear"); show(); }} }} void Display() { //show(); printf("ntEnter the file name: "); scanf("%s",fn); fp1=fopen(fn,"r"); if(fp1==NULL) { printf("ntFile not found!"); int fn; scanf("%d",&fn); switch(fn) { default:system("clear"); show(); } } system("clear"); look(); while(!feof(fp1)) {
  • 25. c=getc(fp1); printf("%c",c); } int del; scanf("%d",&del); switch(del) { default:system("clear"); show(); } end1: fclose(fp1); //menu(); //system("clear"); //printf("n"); //show(); } void Delete() { system("clear"); look(); printf("ntEnter the file name: "); scanf("%s",fn); fp1=fopen(fn,"r"); if(fp1==NULL) { system("clear"); look(); printf("ntFile not found!n"); int ff; scanf("%d",&ff); switch(ff) { default:system("clear"); show(); } }
  • 26. fclose(fp1); if(remove(fn)==0) { printf("nntFile has been deleted successfully!"); int de; scanf("%d",&de); switch(de) { default:system("clear"); show(); break; } } else system("clear"); look(); printf("ntError!n"); show(); } void Append() { system("clear"); look(); printf("ntEnter the file name: "); scanf("%s",fn); fp1=fopen(fn,"r"); if(fp1==NULL) { system("clear"); look(); printf("ntFile not found!"); int nu; scanf("%d",&nu); switch(nu) { default:system("clear"); show();
  • 27. } goto end3; } while(!feof(fp1)) { c=getc(fp1); printf("%c",c); } fclose(fp1); printf("ntType the text and press ESCAPE to append.n"); fp1=fopen(fn,"a"); while(1) { c=getchar(); //if(c==19) //goto end3; if(c==13) { c='n'; printf("nt"); fputc(c,fp1); } else if(c==27) { system("clear"); show(); } else { printf("%c",c); fputc(c,fp1); } } end3: fclose(fp1); system("clear"); menu(); }
  • 28. SAMPLE INPUTS This programme will take some inputs for working with a file. Some inputs: Name:sanjay kumar chakravarti Age:20 Selection of menu: