हेलो दोस्तों !
आज की इस पोस्ट में हम C programming language की मदद से एक simple text editor बनाना सीखेंगे। तो दोस्तों अगर आप इस project को बनाना सीखना चाहते है तो इस पोस्ट को अंत तक जरूर पढ़े।
इस पोस्ट के मुख्य टॉपिक्स निन्म है :-
- Project overview.
- Project की coding के steps.
- project के important concept.
- Project source code.
- Project output video.
1.Project overview :-
2.Project की coding के steps :-
3.project के important concept :-
4.Project source code :-
Project source code :-
#include< stdio.h >
#include< stdlib.h >
#include< conio.h >
#include< graphics.h >
/*function declaration */
void drawBody(void);
int saveContent(int);
int input(void);
FILE *data=NULL;
char content[1024];
char str[1];
int index=0,index2=98,index3=60;
int indexing=0,checkSaved=0;
int saveContent(int check)
{
char ch,fileName[50];
clrscr();
if(check==2)
{
settextstyle(1,0,2);
setcolor(4);
outtextxy(170,150,"Sorry! writing limit is over");
settextstyle(1,0,3);
setcolor(0);
outtextxy(140,170,"Do you want to save content");
outtextxy(140,200,"Press Y for yes and N for no");
again:
fflush(stdin);
ch=getch();
if(ch=='Y'||ch=='y')
{
data=fopen("testfile.txt","w");
if(data==NULL)
{
outtextxy(210,200,"System error");
}
fputs(content,data);
fclose(data);
clrscr();
settextstyle(1,0,3);
setcolor(1);
outtextxy(140,200,"Content is successfully saved");
}else if(ch=='N'||ch=='n')
{
exit(0);
}else
{
clrscr();
setcolor(4);
outtextxy(190,200,"Invalid Key Try again");
goto again;
}
return 5;
}else if(check==1)
{
settextstyle(1,0,3);
setcolor(0);
outtextxy(140,170,"Do you want to save content");
outtextxy(140,200,"Press Y for yes and N for no");
again1:
fflush(stdin);
ch=getch();
if(ch=='Y'||ch=='y')
{
data=fopen("testfile.txt","w");
if(data==NULL)
{
outtextxy(210,200,"System error");
}
fputs(content,data);
fclose(data);
clrscr();
settextstyle(1,0,3);
setcolor(1);
outtextxy(140,200,"Content is successfully saved");
}else if(ch=='N'||ch=='n')
{
exit(0);
}else
{
clrscr();
setcolor(4);
outtextxy(190,200,"Invalid Key Try again");
goto again1;
}
}
return 5;
}
int input()
{
char ch,ch2;
if(kbhit())
{
ch=getch();
if(ch==27)
{
data=fopen("testfile.txt","r");
if(data==NULL)
{
outtextxy(210,200,"System error");
}
while(!feof(data))
{
getc(data);
checkSaved++;
}
fclose(data);
return 1;
}else if(ch==13)
{
content[indexing]='\n';
indexing++;
index2=98;
index3+=15;
if(index3>=380&&index3<=395)
{
return 2;
}
}else if(ch==8)
{
if(index3>=60&&index3<=65)
{}else
{
indexing--;
index2-=8;
if(index2>=92&&index2<=98)
{
index2=540;
index3-=15;
}
}
}else if(ch==9)
{
data=fopen("testfile.txt","w");
if(data==NULL)
{
outtextxy(210,200,"System error");
}
fputs(content,data);
fclose(data);
}else
{
setcolor(10);
settextstyle(0,0,0);
str[0]=ch;
if(ch>=32&&ch<=126)
{
content[indexing]=ch;
outtextxy(index2,index3,str);
index2+=8;
indexing++;
if(index2>=540&&index2<=548)
{
index2=98;
index3+=15;
if(index3>=380&&index3<=390)
{
return 2;
}
}
}
}
}
return 0;
}
void drawBody()
{
setcolor(5);
settextstyle(3,0,3);
outtextxy(200,20,"SIMPLE TEXT EDITOR");
setcolor(5);
settextstyle(3,0,1);
outtextxy(5,170,"Press Esc");
outtextxy(10,200,"To Exit");
outtextxy(555,170,"Press Tab");
outtextxy(560,200,"To save");
outtextxy(580,230,"File");
setcolor(1);
setlinestyle(0,1,3);
rectangle(90,50,550,400);
}
void main()
{
int gd=0,gm,end=0;
clrscr();
initgraph(&gd,&gm,"");
while(end!=5)
{
drawBody();
end=input();
if(end==2)
{
if((checkSaved>=indexing)||(checkSaved==0&&indexing==0))
{
exit(0);
}else
{
end=saveContent(end);
}
}else if(end==1)
{
if((checkSaved>=indexing)||(checkSaved==0&&indexing==0))
{
exit(0);
}else
{
end=saveContent(end);
}
}
}
getch();
closegraph();
}
5.Project output video :-
दोस्तों अगर आप इस text editor project का आउटपुट देखना चाहते है की यह कैसे वर्क कर रहा है इसमें क्या-क्या फीचर है। तो आप हमारी यह वीडियो देख सकते है हमने इस वीडियो में इस प्रोजेक्ट को रन करके दिखाया है और साथ में इस प्रोजेक्ट में यूज़ किये गए C language के कुछ important concept को भी समझाया है तो अगर आप इस वीडियो को you tube पर देखना चाहते है तो नीचे दिए लिंक पर क्लिक करके वीडियो देख सकते है।
इन पोस्ट को भी पढ़े :-
Author :- तो दोस्तों अब हमारी यह पोस्ट ख़त्म होती है हम आशा करते है की आपको हमारी यह पोस्ट जरूर पसंद आई होगी और आप text editor का project C programing language की मदद से बनाना सीख गए होंगे। तो दोस्तों आज के लिए बस इतना ही फिर मिलेंगे ऐसी ही किसी और मजेदार पोस्ट में तब तक के लिए अलविदा !
0 Comments
Do not enter any spam comments please.