Skip to content
EMPS intranet

Back to top
Hi!   Hi!           Start program

Try stepping through the code


  Value and type of last evaluated expression: Address of array element: Address of array elementx:  (none)

Your browser does not support the canvas element which will make some the features unavailable.

If you are using Internet Explorer within the University of Exeter try going to the Settings menu (probably the gear shape at the top right of this page), selecting "Compatibility View settings", unchecking "Display intranet sites in Compatibility View" and reloading this page.

Code

 Header...
void skipline (void);
int main(){ » int x, y; » while (1==1) { » printf("Please enter two integers > 0\n"); » if (scanf("%d %d", &x, &y)!=2) skipline(); else if (x<=0||y<=0) printf("Only integers greater than zero are allowed\n"); else break; » printf("\n\tPlease try again.\n\n"); } » printf("Read: %d %d\n", x, y); » return 0; }
...
// // Read and discard the rest of the line from stdin, printing it so // the user knows what's going on. // void skipline(void){ » int i; » printf("\nSkipping unexpected input: "); » while ((i=getchar())!='\n') { » if (i==EOF) { » printf("End of standard input\n"); » exit(1); } » putchar(i); } » putchar('\n'); }
...
Memory

skipline()

128
129
130
131
i = 134530171

main()

172
173
174
175
x = 1741807249
176
177
178
179
y = -1767824594

NB: the actual memory address of each variable is the
address shown plus 4293130776 (0xFFE3FA18).

Show Advanced options

.

Input was:

1 q
1 2

Show output (Before looking at the output, work out what you think it put should be and see if you are right.)

Output

Please enter two integers > 0

Skipping unexpected input: q

	Please try again.

Please enter two integers > 0
Read: 1 2
                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Share
Back to top