🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #5376

Re: Reading Ctrl-C in TC++

#5376
From: Andrew Zimmerman
Date: Fri, 22 Mar 1991 12:24
38 lines
1908 bytes
In article <4729@gumby.Altos.COM> jerry@altos.COM (Jerry Gardner) writes:
>In article <lee.669434518@chsun1> lee@chsun1.uchicago.edu (Dwight A Lee) writes:
>}I'm writing a program in the ANSI C mode of Turbo C++ 1.01, and I want
>}to be able to read control-C just like any other character.  Right now
>}I'm using getch(), but when control-C is pressed, it acts as if I
>}typed control=Break.
>}
>}Is there a way to disable this behavior and just have getch() return
>}0x03 when control-C is pressed?  I would like to do this from within
>}the program.  Or do I have to install my own... keyboard interrupt
>}somehow?  I am familiar with the concept but have never used
>}interrupts on the MS-DOS PC.
>

    I just tried the following program under Turbo C++ 1.00

main()
{
    int c;

    while((c = getch()) != 'q')
    {
        printf("%c\n",c);
    }
}
I compiled using tcc -A tst.c (-A is for ansi mode I believe)

It doesn't seem to have the same behavior that the original poster was 
upset about.  getch handles the ^c without any problem.  In fact, it
loves it when I type a ^c.  (a very subtle bit of humor.  Run the program) :-)

Turbo C++ also has the getcbrk and setcbrk functions that might be of use.

Is there a possiblity that it has something to do with the version of DOS?
(I'm running Zenith 3.3+)

Andrew
zimmer@calvin.stanford.edu
Technical Details
Message-ID: <1991Mar22.122417.7845@neon.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uwm.edu!bionet!snorkelwacker.mit.edu!bu.edu!stanford.edu!neon.Stanford.EDU!calvin!zimmer

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uwm.edu!bionet!snorkelwacker.mit.edu!bu.edu!stanford.edu!neon.Stanford.EDU!calvin!zimmer
From: zimmer@calvin.stanford.edu (Andrew Zimmerman)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Reading Ctrl-C in TC++
Keywords: getch TC++ Borland break ctrl
Message-ID: <1991Mar22.122417.7845@neon.Stanford.EDU>
Date: 22 Mar 91 12:24:17 GMT
Sender: news@neon.Stanford.EDU (USENET News System)
Organization: Stanford University
Lines: 38