title: How to get around no backspace when ICANON in non-canonical
body: <p>I am using termios as suggested in a previous question I asked but now am asking if there <strong>is a way get backspace to work whilst using termios in non-canonical mode</strong>. I am using termios to have not have an <code>echo</code> If I use <code>&amp;=ECHO</code> and <code>&amp;=ICANON</code> this is the result I want, the keyboard input is sent to putchar() as soon as the key is press and displayed but the <code>'\b'</code> key is display as <code>hex</code>, if I do the opposite I can't see the text till enter is pressed but <code>'\b'</code> works.
  I have looked up the <a href="http://www.mkssoftware.com/docs/man5/struct_termios.5.asp" rel="nofollow">manual</a> and some other forums that and they said " not possible just don't make any mistakes", this would make sense seeing as how when I don't enter my password correctly in in a terminal on Ubuntu I can't backspace and change it. But I was making sure I haven't missed anything in the manual.</p>
  
  <p>Code is to get input from stdin and not display empty lines.</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;termios.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;stdio.h&gt;
  #define ECHOFLAGS (ECHO)
  
  int setecho(int fd, int onflag);
  int first_line(int *ptrc);
  
  int main(void){
  
  struct termios old;
  tcgetattr(STDIN_FILENO,&amp;old);
  
  
  setecho(STDIN_FILENO,0);
      int c;
      while((c = getchar())!= 4) //no end of file in non-canionical match to control D
          first_line(&amp;c);
  tcsetattr(STDIN_FILENO,&amp;old);    
  return 0;
  
      }
  
  
  int setecho(int fd, int onflag){
      int error;
      struct termios term;
  
      if(tcgetattr(fd, &amp;term) == -1)
          return -1;
      if(onflag){ printf("onflag\n");
          term.c_lflag &amp;= ECHOFLAGS ; // I know the onflag is always set to 0 just 
          term.c_lflag &amp;=ICANON;      // testing at this point
      }
      else{ printf("else\n");
          term.c_lflag &amp;= ECHO;
          term.c_lflag &amp;=ICANON;
  
      }
  
      while (((error = tcsetattr(fd, TCSAFLUSH, &amp;term)) ==-1 &amp;&amp; (errno == EINTR)))
              return error;
  }
  
  int first_line(int *ptrc){
      if (*ptrc != '\n' &amp;&amp; *ptrc != '\r'){
              putchar(*ptrc);
          while (*ptrc != '\n'){
              *ptrc = getchar();
              putchar(*ptrc);
              }
  
  
      }
      else return 0;
  
      return 0;
  }
  </code></pre>
  
  <p>Thanks Lachlan</p>
  
  <p>P.S on a side point in my research I noticed someone saying Termios isn't "Standard C" is this because it is system dependant? (only for comments)</p>