Question: I have been trying to access the elements in stateStruct but have no idea how to do this in C exactly take this merely as

 I have been trying to access the elements in stateStruct butI have been trying to access the elements in stateStruct but have no idea how to do this in C

exactly take this merely as a hint. You may have to re-code this to make it do what you want, but this should help you get started. Remember not to change statestruct or print state. - instruction-level simulator for LC3101 */ #include #include #define NUMMEMORY 65536 - maximum number of words in smory / #define NUMREGS B / number of machine registers */ define MAXLINELENGTH 1000 typedef struct statestruct int per int mem[NUMMEMORY]: int reg (NUMREGS); int numMemory; stateType: void printState (stateType *): int main(int arge, char *argv (1) 1 char line [MAXLINE LENGTH) stateType state; FILE *filePtr if large 1-2) printf("error: usage: Is ", argv[0]: exit(1); } filePtr - fopen (argv[1], ""); if (filePtr -- NULL) { printf("error: can't open file is", argv[1]); perror ("fopen"); exit(1); * read in the entire machine-code file into memory */ for (state.numMemory = 0; fgetsline, MAXLINE LENGTH, filet) - NULL; state.numMemory++) { if (sscanf (line, "d", state.mem+state.numMemory) - 11+ printf("error in reading address Id ", state.nummemory exit(1); printf ("memory [d]=%d ", state.nummemory, state.mem[state.numMemory]); exactly take this merely as a hint. You may have to re-code this to make it do what you want, but this should help you get started. Remember not to change statestruct or print state. - instruction-level simulator for LC3101 */ #include #include #define NUMMEMORY 65536 - maximum number of words in smory / #define NUMREGS B / number of machine registers */ define MAXLINELENGTH 1000 typedef struct statestruct int per int mem[NUMMEMORY]: int reg (NUMREGS); int numMemory; stateType: void printState (stateType *): int main(int arge, char *argv (1) 1 char line [MAXLINE LENGTH) stateType state; FILE *filePtr if large 1-2) printf("error: usage: Is ", argv[0]: exit(1); } filePtr - fopen (argv[1], ""); if (filePtr -- NULL) { printf("error: can't open file is", argv[1]); perror ("fopen"); exit(1); * read in the entire machine-code file into memory */ for (state.numMemory = 0; fgetsline, MAXLINE LENGTH, filet) - NULL; state.numMemory++) { if (sscanf (line, "d", state.mem+state.numMemory) - 11+ printf("error in reading address Id ", state.nummemory exit(1); printf ("memory [d]=%d ", state.nummemory, state.mem[state.numMemory])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!