Program

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

PROGRAM: #include<stdio.h> #include<conio.h> #include<stdlib.

h> #define MAX 10 struct estab { char csect[10],symname[10]; long int add; int length; }table[MAX]; void main() { FILE *f1,*f2; char ip[10]; long int i,count=0,start,length,loc; clrscr(); f1=fopen("lkin.dat","r"); f2=fopen("lkout.dat","w"); printf("Enter the location where the pgm has to be loaded:"); scanf("%lx",&start); fprintf(f2,"CSECT Tsymname Taddress Tlength\n"); rewind(f1); while(!feof(f1)) { fscanf(f1,"%s",ip); if(strcmp(ip,"H")==0) { fscanf(f1,"%s",ip); strcpy(table[count].csect,ip); strcpy(table[count].symname,"\0"); fscanf(f1,"%s",ip); table[count].add=atoi(ip)+start; fscanf(f1,"%s",ip); length=atoi(ip); table[count++].length=atoi(ip); fscanf(f1,"%s",ip); } if(strcmp(ip,"D")==0) { fscanf(f1,"%s%lx",ip,&loc); while(strcmp(ip,"R")!=0) { strcpy(table[count].csect,"\0"); strcpy(table[count].symname,ip); table[count].add=loc+start; table[count++].length=0;

fscanf(f1,"%s%lx",ip,&loc); } while(strcmp(ip,"T")!=0) fscanf(f1,"%s",ip); } if(strcmp(ip,"T")==0) while(strcmp(ip,"E")!=0) fscanf(f1,"%s",ip); fscanf(f1,"%s",ip); start=start+length; } for(i=0;i<count;i++) fprintf(f2,"%s\t%s\t%lx\t%d\n",table[i].csect,table[i].symname,table[i].add,table[i] .length); getch(); }

OUTPUT: LKIN.DAT H PROGA 000000 000070 D LIST 000040 ENDA R LISTB ENDB LISTC ENDC T 000020 10 03201D 77100004 M 000024 05 +LISTB M 000054 06 +LISTC M 000058 06 +ENDC M 000064 06 +LISTB E 000000 LKOUT.DAT CSECT PROGA Tsymname LIST ENDA Taddress 3000 3040 3054 Tlength 70 0 0

000054 150014

PROGRAM: #include<stdio.h> #include<conio.h> #include<ctype.h> #include<dos.h> #include<iostream.h> #include<fstream.h> char filename[15]; char buff[1000]; int cx,cy,count; void c_pos() { cx=wherex(); cy=wherey(); gotoxy(35,1); cout<<"\nType your text and then press escape key\n"; gotoxy(100,100); cprintf("%2d%2d",cy,cx); gotoxy(cx,cy); } void main() { char ch,c; ofstream outfile; ifstream infile; clrscr(); c_pos(); cx=wherex(); cy=wherey(); while(c!=27) { c=getch(); switch(c) { case 80:gotoxy(cx,cy+1); break; case 77:gotoxy(cx+1,cy); break; case 72:gotoxy(cx,cy-1); break; case 75:gotoxy(cx-1,cy); break; case 32:printf(" "); buff[count++]=' '; break; case 13:gotoxy(1,cy+1);

buff[count++]='\n'; break; default:if((c>=65 && c<=122)|| (c>=48 && c<=57)) cprintf("%c",c); break; } buff[count++]=c; c_pos(); } cprintf("\n\n Do U want to Save?(y/n):"); scanf("%c",&c); if((c=='y')||(c=='Y')) { cprintf("\n\nEnter the filename with extension in 8 characters only:"); scanf("%s",filename); outfile.open(filename,ios::out); outfile<<buff; outfile.close(); cout<<"\nDo U want to open(y/n):\n "; ch=getch(); cout<<ch; { if((ch=='y')||(ch=='Y')) { cprintf("\nEnter the filename to open:"); scanf("%s",&filename); infile.open(filename,ios::in); infile.get(buff,count,'*'); gotoxy(90,1); printf("%s",buff); getch(); infile.close(); } } } }

OUTPUT: simple text editor program Type your text and then press escape key 213 Do U want to Save?(y/n):y Enter the filename with extension in 8 characters only:t.txt Do U want to open(y/n): y Enter the filename to open:t.txt simple text editor program

You might also like