X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <45EEEB0C.2070109@mainstreetsoftworks.com> Date: Wed, 07 Mar 2007 11:40:44 -0500 From: Brad House User-Agent: Thunderbird 1.5.0.9 (X11/20070129) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: line feed References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Sterten AT aol DOT com wrote: > > on this computer in my C-programs > printf("%c",10); > prints ascii 13 and ascii 10. > > While on another computer it only printed acii 10 > and I used print("%c%c",13,10) for the above purpose. > > But that means, the old programs no longer work correctly ?!? > > Is it possible to check the system and then branch to > whatever suitable to print , so the programs work universally ? First of all, in C, you have handy escape codes, use '\r' for 13 and '\n' for 10, so you don't have to use printf format codes. Next, you can do something like this: #if defined(_WIN32) || defined(__DJGPP__) # define NEWLINE "\r\n" #else # define NEWLINE "\n" #endif printf("Hello World" NEWLINE); And get the proper behavior on your expected systems. And yes, there should NOT be a comma between "Hello world" and NEWLINE as C allows "H" "e" "l" "l" "o" " " "W" "o" "r" "l" "d" to be equivalent to "Hello World"