Read and Load Simulator
Read and Load Simulator
Read and Load Simulator
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++;
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