To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 14519
14518  |  14520
Subject: 
Re: how does a line end?
Newsgroups: 
lugnet.cad
Date: 
Sat, 7 Apr 2007 15:01:10 GMT
Viewed: 
1584 times
  
Tore Eriksson schrieb:
In lugnet.cad, Chris Phillips wrote:

It is very easy for a programmer (regardless of the OS they are using) to
create programs that do not use "proper" line breaks.  If you doubt it,
answer this quiz without using any reference materials:

| 1.  Which of the following is "correct"?
|     a.  printf("Hello, world!\r");
|     b.  printf("Hello, world!\n");
|     c.  printf("Hello, world!\r\n");
|     d.  printf("Hello, world!\n\r");
|
| 2.  In each of the above cases, what byte sequence will appear in the
  output stream?

1. I always use alt. b. "printf("Hello, world!\n");" But as a self-made hobby
programmer not knowing all the tweeks and geeks, I wouldn't be surprised if the
interpretation of this may vary from one IDE to another, or if there is an .ini
file or global veraible somewhere that sets the output of \n.

2. As I always use \n, I don't know the output of the other alternatives. \n
gives the sequence "\13\10", or "0x0C 0x0A" in hexadecimals from Borland TC++
v3.0.

- - - - -

There was a Swedish finiance minister that said it's safer to have both a belt
and suspenders. I think the optimal fool-proof way to go is to make software as
liberal as possible when it comes to input, but conservative on output. Make it
able to read Mac's special LF but write strictly CR+LF.

/Tore
After read all this and also after I have had a look at
http://en.wikipedia.org/wiki/Line_feed I think that Tore is right by
saying "read all and save secure".
Do avoid for future discussions this should be mentioned also in the
LDraw Specification. Otherwise in some weeks we will have a same
discussion again, because who cares about a line ending? It should work.
But if the community uses different systems we will have that problem
over the years again and again.
I just have updated DATHeader to also read unix files, but always write
DOS files.

mikeheide



Message is in Reply To:
  Re: how does a line end?
 
(...) 1. I always use alt. b. "printf("Hello, world!n");" But as a self-made hobby programmer not knowing all the tweeks and geeks, I wouldn't be surprised if the interpretation of this may vary from one IDE to another, or if there is an .ini file (...) (17 years ago, 7-Apr-07, to lugnet.cad, FTX)

24 Messages in This Thread:











Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR