/* I need some advice on program bellow,this program is text program
in this program by pressing arrow key you can change your position
in the text and by enter key you can break a line and move the rest of the
line to a new line but this program dosen`t work properly.*/
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void pos(char);
void text();
int i, j,k,x=0,y=0,s=0;
char txt[41][79],st[79],ch;
int main()
{
clrscr();
for(j=0;j<41;j++)
for(i=0;i<79;)
txt[j][i]=32;
text();
return 0;
}
//******************************************((functions))********************************
void text(){
for(j=0;j<41;j++){
for(i=0;i<79;){
ch=getch();
if(isalpha(ch) || isdigit(ch)|| ch==32){
x++;
i++;
txt[j][i]=ch;
putch(ch);
}else
if (ch==13||ch==0){
pos(ch);
}else
if (ch=='=')
goto last;
}//end of for
y++;
}//end of outer for
last:
}
//****************************
void pos(char ch){
if(ch==13){
for( int k=i;k<=76;k++,s++)
st[s]=txt[j][k];
y++;
x=0;
printf("\n");
puts(st);
for( int t=j;t<41;t++){
for(int i=0;i<=78;i++){
putch(txt[t][i]);
}
printf("\n");
}
}//end of enter
if(ch==0){
ch=getch();
if(ch==72){
y=y-1;
gotoxy(x,y);
}
else if(ch==80){
y=y+1;
gotoxy(x, y);
}
else if(ch==75){
x=x-1;
gotoxy(x,y);
}
else if(ch==77){
x=x+1;
gotoxy(x,y);
}
}
}
//***********************************