Thread: help me understand the printf codes

  1. #1
    Registered User
    Join Date
    Sep 2016
    Posts
    1

    Question help me understand the printf codes

    Hi everyone

    I got this line of code.

    printf ("\033[2J\033[1;1H");

    My program is working with rs232 terminal.

    Can someone help me understand what does this line do?
    I know it clears the screen.. but how exactly?

    Thanks!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    \033 is an octal escape sequence, which evaluates to the ESC character code (decimal 27)

    The \033[ pair is known as a CSI
    ANSI escape code - Wikipedia, the free encyclopedia

    You need a terminal which understands these sequences if you want to observe the intended effects, otherwise you just see random garbage printed on screen.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Validate area codes within a list of area codes
    By Staja24 in forum C Programming
    Replies: 9
    Last Post: 05-06-2015, 09:28 PM
  2. Having 3 codes into 1
    By JacobC in forum C Programming
    Replies: 11
    Last Post: 11-13-2011, 04:40 PM
  3. Need some C++ codes...
    By blah569 in forum C++ Programming
    Replies: 5
    Last Post: 10-05-2005, 02:21 PM
  4. make printf using printf?
    By germaneater in forum C Programming
    Replies: 9
    Last Post: 11-10-2004, 10:58 PM
  5. converting scan codes to ascii codes
    By stupid_mutt in forum C Programming
    Replies: 11
    Last Post: 01-25-2002, 04:06 PM

Tags for this Thread