Em vô dụng quá, tìm hoài không ra lỗi, lỗi của bài này là ở chỗ, soạn thảo văn bản mổ phỏng của word nhưng mà em vẫn chưa tìm ra cái lỗi chèn thêm vào nhưng lại xóa cái mình đã nhập vào... Và còn chỗ xuất ra chưa xuất được.. Đau đầu quá.........
Code:
#include<conio.h>
#include<stdio.h>
#include<string.h>
/*********************************************************/
main()
{
int n=0,i,j;
char mang[1000];
unsigned char counter_enter;
int dght=2,cotht=1;
char ch;
clrscr();
printf("\n Nhap chuoi:");printf("\n\r");
while(ch!=27)
{
/*===========nhap va in ra ki tu vua nhap=======*/
ch = getch();
mang[n++] = ch;
/*=============kiem tra trang dong============*/
if((cotht>=80))
{
cotht=1;
dght++;
}
else
if(ch==13)
{
cotht=1;
dght++;
}
/*=============hieu hinh lui'<-'============*/
if(ch>=0&&ch<=31)
{
if(ch==0)
{
ch=getch();
if(ch==75)
{
gotoxy(wherex()-1,wherey());
dght=dght;
cotht=cotht-1; /******************/
if (cotht<1)
{
dght=dght-1;
cotht=80;
gotoxy(cotht,dght);
if(ch==75)
{
//mang[n]=mang[n-1];
dght=dght;
cotht=cotht-1;
gotoxy(cotht,dght);
} /****************/
} /*****************/
}
// printf("%d,%d",wherex(),wherey());
/*=============hieu chinh tien'->'============*/
if(ch==77)
{
gotoxy(wherex()+1,wherey());
dght=dght;
cotht=cotht+1;
if (cotht>=80)
{
dght=dght+1;
cotht=1;
gotoxy(cotht,dght);
if(ch==77)
{
dght=dght;
cotht++;
gotoxy(cotht,dght);
} /****************/
}
}
// printf("\n%d,%d",wherex(),wherey());
/*=============hieu chinh len============*/
if(ch==72)
{
gotoxy(wherex(),wherey()-1);
dght=dght-1;
cotht=cotht; /******************/
if (dght<1)
{
dght=25;
cotht=cotht;
gotoxy(cotht,dght);
if(ch==72)
{
dght=dght-1;
cotht=cotht;
gotoxy(cotht,dght);
} /****************/
} /*****************/
// printf("\n%d,%d",wherex(),wherey());
}
/*=============hieu chinh xuong dong============*/
if(ch==80)
{
gotoxy(wherex(),wherey()+1);
dght=dght+1;
cotht=cotht; /******************/
if (dght>10)
{
j=1;
for (i=0;i<n;i++)
{
if(mang[i]>31)
{
dght=2;
j++;
if(mang[i]==13)
gotoxy(j,dght);
}
if(mang[i]==13) break;
} /**********/
if(ch==80)
{
// mang[n]=mang[n-1];
dght=dght+1;
cotht=cotht;
gotoxy(cotht,dght);
} /****************/
} /*****************/
// printf("\n%d,%d",wherex(),wherey());
}
if(ch==83)
{
// cotht--;
// i=i-1;
// gotoxy(wherex()-1,wherey());
mang[n-1]=mang[n];
gotoxy(wherex()-1,wherey());
putchar(mang[n-1]);
}
}
}
else
{
cotht++;
putchar(mang[n-1]);
}
if(ch==8)
{
//cotht--;
//i=i-1;
gotoxy(wherex()-1,wherey());
mang[n-1]=mang[n-2];
gotoxy(wherex(),wherey());
putchar(mang[n-1]);
}
/*=============ngung nhap van ban============*/
if(ch==13)
puts("");
}
// for
return 0;
}