TurboC 1.5 Stack check
haskins at s.cs.uiuc.edu
haskins at s.cs.uiuc.edu
Tue Aug 2 01:16:00 AEST 1988
I was testing the Stack Overflow Check feature of TurboC 1.5 and came up
with something strange...here's the program:
#include <stdio.h>
#include <conio.h>
void call_routine(int); /* prototype */
main()
{
int j;
j = 0;
call_routine(j);
}
void call_routine(int j) /* 'modern' style */
{
gotoxy(1,1); /* top o' page */
cprintf("level = %d",j);
call_routine(j + 1);
}
Model size set to Huge, Test Stack Overflow ON (no duh)
Now, when this is run, it goes for 405 iterations, then prints a message
Stack Overflow!
and quits, putting me back at the DOS prompt (or press a key to return...)
However, when I do a 'printf(..' instead of a 'cprintf(...)', it goes through
393 iterations, then prints 'lev' and hangs, allowing a warm start (thank
God).
What's the difference between whether cprintf or printf is used? And in
general, should cprintf be used over printf for printing on the screen?
Please post replies here.
--------------------------------
Lloyd M. Haskins
Department of Computer Science -- University of Illinois
haskins at cs.uiuc.edu
More information about the Comp.lang.c
mailing list