what is the use of carriage return (\r), form feed(\f),bell(\a) in c++?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vamsirays
    New Member
    • Jul 2010
    • 7

    what is the use of carriage return (\r), form feed(\f),bell(\a) in c++?

    how can we use these escape sequence, and also octal number(\010) and hexadecimal number given(\xhh)?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Well they would be of use any time you would want to use a carriage return or forum feed or bell or some other non-printable character defined using hex or octal in a string or array of bytes.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      In general, character or string literals contain printable ASCII characters (for example, 'A', "ABC def 123.") Sometimes you want to include one or more nonprintable characters in a string. That's what escape sequences are for. Some nonprintable characters are used so often that shorthand sequences were defined for them ("\r", '\n', "\a", etc.). If there is no shorthand escape sequence for the code you want, therer is always the option of using a numeric sequence ('\x1' or "\001"). You can choose between hexadecimal or octal based on your personal preference.

      Comment

      Working...