From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Conio's cprintf problem Date: Sun, 22 Mar 1998 20:03:31 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 51 Message-ID: <3515B4E3.5462@cs.com> References: <351553C4 DOT EE644B06 AT netrover DOT com> NNTP-Posting-Host: ppp238.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Nicolas Blais wrote: > > Hi, whenever I compile and run this code, the "World!" string is placed > below the "Hello" but after the "o". How do I make it got in the > beggining of the line and not and the end of Hello. Here's what it shows > on the screen: In MS-DOS boxes, end-of-line is represented as a combination of line feed and carriage return characters. When you use stdio functions (printf, etc.), this is done for you automatically when you print the '\n' character. When you use conio functions, you have to use both yourself. Additional bugs in your code: - It's clrscr(), not clrscr; - main() must return an integer according to ANSI C. - The return statement is correct, but it doesn't agree with the return type of main(). Additional comment: - There's no point in writing this code as C++ since it uses no C++ constructs. - You don't need parentheses around the argument to return. Corrected code follows: #include #include int main(void) { clrscr(); textcolor(RED); cprintf("Hello\n\r"); highvideo(); cprintf("World!\n\r"); textcolor(LIGHTGRAY); return 0; } hth! -- --------------------------------------------------------------------- | John M. Aldrich | "Animals can be driven crazy by pla- | | aka Fighteer I | cing too many in too small a pen. | | mailto:fighteer AT cs DOT com | Homo sapiens is the only animal that | | http://www.cs.com/fighteer | voluntarily does this to himself." | ---------------------------------------------------------------------