From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: getkey() Date: 19 Oct 2001 16:16:14 GMT Organization: Aachen University of Technology (RWTH) Lines: 31 Message-ID: <9qpjke$vu$1@nets3.rz.RWTH-Aachen.DE> References: <9qpj2s$96v$1 AT cyan DOT nl DOT gxn DOT net> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1003508174 1022 137.226.32.75 (19 Oct 2001 16:16:14 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 19 Oct 2001 16:16:14 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Bart van den Burg wrote: > hi > I've got a problem with this function: > -------------------------------- > void playGame() { > char x; > char y; > x = getkey(); > char buffer[2]; ^^^^^^^^^^ This buffer is probably too short for what you're trying to do. At the very least, you should limit the maximal output width of your sprintf() format accordingly. > sprintf(buffer, "%d", char(x)); You don't show what function "char" is. And I'm quite sure you don't want the code number of the character you input, as a decimal string, which is what this sprintf() call will give you. What you want would be much easier to do like this: buffer[0] = x; buffer[1] = '\0'; This makes the string in "buffer" read "1", if you typed '1'. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.