Welcome to Dream.In.Code
Become a Java Expert!

Join 149,947 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,373 people online right now. Registration is fast and FREE... Join Now!




carriage return?!?

 
Reply to this topicStart new topic

carriage return?!?

csgwms
14 Sep, 2008 - 04:57 PM
Post #1

New D.I.C Head
*

Joined: 7 Aug, 2008
Posts: 10

what does a carriage return do exactly? i tested it in the computer and it brought the text down to another line:o help! but people tell me it doesnt

This post has been edited by csgwms: 14 Sep, 2008 - 04:58 PM
User is offlineProfile CardPM
+Quote Post

skin__
RE: Carriage Return?!?
14 Sep, 2008 - 05:15 PM
Post #2

New D.I.C Head
*

Joined: 20 May, 2008
Posts: 37

What? Are you talking about \n? That's the escape sequence for starting text on a new line.
User is offlineProfile CardPM
+Quote Post

pbl
RE: Carriage Return?!?
14 Sep, 2008 - 05:29 PM
Post #3

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,574



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(csgwms @ 14 Sep, 2008 - 05:57 PM) *

what does a carriage return do exactly? i tested it in the computer and it brought the text down to another line:o help! but people tell me it doesnt

Depends of your OS. Unix/Linux and Windows react differently to them.
User is online!Profile CardPM
+Quote Post

csgwms
RE: Carriage Return?!?
14 Sep, 2008 - 05:31 PM
Post #4

New D.I.C Head
*

Joined: 7 Aug, 2008
Posts: 10

no the escape sequence \r on windows (compiler was jcreator if it matters)

This post has been edited by csgwms: 14 Sep, 2008 - 05:32 PM
User is offlineProfile CardPM
+Quote Post

baavgai
RE: Carriage Return?!?
14 Sep, 2008 - 06:12 PM
Post #5

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,281



Thanked: 136 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua, Cheese

My Contributions
A carriage return returns the carriage. tongue.gif Seriously, a long time ago when type writers ruled the world and some computer were real dumb terminals, the ascii code told the hardware to physically reset the moving part that shifts the paper over back to home. The effect was the cursor returns the start of the line.

Note, it didn't move the line, just reset the machine to the beginning of it. To actually go to next line, you needed to issue a linefeed. If you issued a linefeed without a carriage return, the paper would go down a line, but not return to the beginning. It makes more sense if you've ever used a typewriter...

Windows does this correctly, using both a CR("\n" or ascii 13) and an LF("\r" or ascii 10) in it's files to indicate the start of a newline.

Unix, knowing it's not a teletype, chooses to do the same thing with one value, "\n". Mac also uses one value, but had to be different and uses the other half of the pair, "\r".

Many systems will translate "\n" as a newline for the OS they're currently on.

Hope that helps.

User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 05:21PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month