Ask your own question, for FREE!
Computer Science 18 Online
OpenStudy (anonymous):

what's the use of carriage return in C? \r

OpenStudy (anonymous):

On a typewriter, the carriage return moves the 'carriage' (the part that holds the paper) to the beginning of the current line. Early printers were basically automated typewriters, so at the end of a line the carriage return instruction '\r' would need to be sent to the printer, followed by a 'newline' command '\n'.

OpenStudy (rsmith6559):

Unix uses linefeeds, '\n'. Windows uses carriage return and linefeeds, "\r\n". Some GUIs on Apple, and pre-OSX Apples use carriage returns, '\r'.

OpenStudy (anonymous):

The language needs a way to preserve line-breaks when the code is shuffled around or compiled.

OpenStudy (anonymous):

Computers are able to recognize a limited set of characters. (these characters are generally encoded in some way: like ASCII, Unicode, etc). This set of characters also contains some special characters, that have special meaning. \r is one of those special characters. The interpretation it gets, depends on the Operating system you are running, not on the programming language you are using. So, if you use \r\n combination in windows, this will produce a new line. In Unix you will have to use \n to create a new line. The \r character only (note it is only one character, not two), gets the interpretation the operating system gives to it.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!