Question: I keep getting the error message to print many times whenever it is not supposed to. I understand the problem is in the way I

I keep getting the error message to print many times whenever it is not supposed to. I understand the problem is in the way I am iterating through the array of structs as I am not finding the value I am looking for every time. I feel as though there is an easy solution that I am missing.

My code:

struct table { char name[30]; int interrupt; int address; };

struct table IVT[8] = { {"overflow",1,1024}, {"divide error",4,1028}, {"breakpoint",9,1032}, {"system timer",55,1036}, {"single step",100,1040}, {"page fault",0,1044}, {"stack segment overrun",88,1048}, {"co-processor not available",255,1052}, };

int key; int sizeOfArray = 8;

int main (void) { for(int i = 0;i

if(key == IVT[j].interrupt) printf("Name of interrupt: %s Starting Address of interrupt: %d ", IVT[j].name, IVT[j].address); else{ printf("Number entered does not correspond to an interrupt "); }

}

My output:

I keep getting the error message to print many times whenever it

Enter a number that corresponds to an interrupt: 1 Name of interrupt: overflow Starting Address of interrupt: 1024 Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Enter a number that corresponds to an interrupt: 2 Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Enter a number that corresponds to an interrupt: 3 Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Enter a number that corresponds to an interrupt: 4 Number entered does not correspond to an interrupt Name of interrupt: divide error Starting Address of interrupt: 1028 Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Enter a number that corresponds to an interrupt: 5 Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt Number entered does not correspond to an interrupt execution time : 8.224 s Process returned o (@xo) Press any key to continue

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!