TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Creating Notepad using C
Rahat pattalbab
Apr 29
2015
Code
11.4
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
Notepad using c.zip
#include < stdio.h >
#include < conio.h >
#include < dos.h >
#include < stdlib.h >
#include < mem.h >
#include < string.h >
char
far * vid = 0xB8000000;
char
a[50000], * str;
int
track[2000], fp = 1, lp = 21, cl = 1, p = 0, t = 0, eat;
/*This function writes a character into video memory.*/
writechar(
char
ch,
int
attr,
int
row,
int
col)
{
char
far * v;
v = vid + row * 160 + col * 2;
* v = ch;
v++;
* v = attr;
}
/*End wrotechar*/
//-----------------------------------------------------------------------/*This function draws a box of given attribute & size*/
drawbox(
int
r1,
int
c1,
int
r2,
int
c2,
int
attr)
{
int
i, j;
for
(i = r1; i <= r2; i++)
{
for
(j = c1; j <= c2; j++)
writechar(
' '
, attr, i, j);
}
}
/*End drawbox*/
//------------------------------------------------------------------------/*This function draws the screen at starting*/
drawscreen()
{
drawbox(0, 0, 0, 79, 120);
drawbox(24, 0, 24, 79, 120);
drawbox(1, 0, 23, 79, 16);
doubleborder(1, 0, 23, 79, 31);
}
/*End drawscreen*/
//------------------------------------------------------------------------/*This function refreshes the screen*/
refreshscreen()
{
int
r, c;
drawbox(2, 1, 22, 78, 16);
}
/*End Refreshscreen*/
//-------------------------------------------------------------------------/*This function draws the double border*/
doubleborder(
int
r1,
int
c1,
int
r2,
int
c2,
int
attr)
{
int
r, c;
writechar(201, attr, r1, c1);
writechar(187, attr, r1, c2);
writechar(200, attr, r2, c1);
writechar(188, attr, r2, c2);
for
(c = (c1 + 1); c <= (c2 - 1); c++)
writechar(205, attr, r1, c);
for
(c = (c1 + 1); c <= (c2 - 1); c++)
writechar(205, attr, r2, c);
for
(r = (r1 + 1); r <= (r2 - 1); r++)
writechar(186, attr, r, c1);
for
(r = (r1 + 1); r <= (r2 - 1); r++)
writechar(186, attr, r, c2);
}
/*End doubleborder*/
//---------------------------------------------------------------------------/*This function draws border of given attribute & size*/
drawborder(
int
r1,
int
c1,
int
r2,
int
c2,
int
attr)
{
int
r, c;
writechar(218, attr, r1, c1);
writechar(191, attr, r1, c2);
writechar(192, attr, r2, c1);
writechar(217, attr, r2, c2);
r = r1;
for
(c = c1 + 1; c <= c2 - 1; c++)
writechar(196, attr, r, c);
r = r2;
for
(c = c1 + 1; c <= c2 - 1; c++)
writechar(196, attr, r, c);
c = c1;
for
(r = r1 + 1; r <= r2 - 1; r++)
writechar(179, attr, r, c);
c = c2;
for
(r = r1 + 1; r <= r2 - 1; r++)
writechar(179, attr, r, c);
}
/*End drawborder*/
//---------------------------------------------------------------------------/*This function draws a line of given attribute*/
drawline(
int
r,
int
c1,
int
c2,
int
attr)
{
int
i;
writechar(195, attr, r, c1);
writechar(180, attr, r, c2);
for
(i = c1 + 1; i <= c2 - 1; i++)
writechar(196, attr, r, i);
}
/*End drawline*/
//---------------------------------------------------------------------------/*This function writes a string in given row & column with given attribute*/
writestring(
char
* p,
int
attr,
int
r,
int
c)
{
int
l, i;
l = strlen(p);
for
(i = 0; i < l; i++)
{
writechar( * (p + i), attr, r, c);
c++;
}
}
/*End writestring*/
//---------------------------------------------------------------------------/*This function saves the content of videomemory from r1,c1 to r2,c2 into main memory using char buffer*/char *savemem(int r1,int c1,int r2,int c2,char *buff)
{
char
far * v;
int
i, j, k = 0, size;
size = (r2 - r1 + 1) * (c2 - c1 + 1) * 2;
buff = (
char
* ) malloc(size);
for
(i = r1; i <= r2; i++)
{
for
(j = c1; j <= c2; j++)
{
v = (vid + i * 160 + j * 2);
* (buff + k) = * v;
k++;
v++;
* (buff + k) = * v;
k++;
}
}
return
(buff);
}
/*End savememo*/
//---------------------------------------------------------------------------/*This function restores the content of main memory into videomemoryfrom r1,c1 to r2,c2 using char buffer*/
restoremem(
int
r1,
int
c1,
int
r2,
int
c2,
char
* buff)
{
char
far * v;
int
i, j, k = 0;
for
(i = r1; i <= r2; i++)
{
for
(j = c1; j <= c2; j++)
{
v = (vid + i * 160 + j * 2);
* v = * (buff + k);
k++;
v++;
* v = * (buff + k);
k++;
}
}
free(buff);
}
/*End restorememory*/
//---------Entire code is with attachment
Create Notepad
C Language
Notepad using C