Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ncar!oddjob!uxc!uxc.cso.uiuc.edu!a.cs.uiuc.edu!s.cs.uiuc.edu!haskins From: haskins@s.cs.uiuc.edu Newsgroups: comp.lang.c Subject: TurboC 1.5 Stack check Message-ID: <207600001@s.cs.uiuc.edu> Date: 1 Aug 88 15:16:00 GMT Lines: 38 Nf-ID: #N:s.cs.uiuc.edu:207600001:000:1075 Nf-From: s.cs.uiuc.edu!haskins Aug 1 10:16:00 1988 I was testing the Stack Overflow Check feature of TurboC 1.5 and came up with something strange...here's the program: #include #include 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@cs.uiuc.edu