Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Read and Load Simulator

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

#include<stdio.

h>
#include<stdlib.h>
char fname[20];
FILE *fp;
int mem[100],pc;
void load()
{
printf("Enter file name:");
scanf("%s",fname);

fp = fopen(fname,"r");
if(fp==NULL)
{
printf("File %s not found.\n",fname);
exit(1);
}

while(fscanf(fp,"%d",&mem[pc])!=-1)
pc++;

source type of data target


void Print()
{ int i;
for(i=0;i<pc;i++)
    {
        printf("%06d/n  ", mem[i]);
    }
                  
}
fclose(fp);
}

int main()
{
int ch;

while(1)
{

printf("1.Load\n2.Print\n3.Run\n4.Exit\n");
printf("Enter your choice (1-4):");
scanf("%d",&ch);
switch(ch)
{
Case 1:
Load();
break;
// Case 2:
//Case 3:
//Case 4:
default:
printf(“Invalid choice”);
}

}
}
mem

0 09020
1 09021
2
… ….

99

First Step:
Start from main function

You might also like