Hi Mike, I found that in libgloss/microblaze/read.c file we are returning (i+ 1) value as below. int read_micro (int fd, char* buf, int nbytes) { int i = 0; for (i = 0; i < nbytes; i++) { *(buf + i) = inbyte(); if ((*(buf + i) == '\n' || *(buf + i) == '\r')) break; } return i + 1; } getchar is failing due to this extra 1 byte(i + 1) that we are returning from this function. I have made changes to the same function as below.. int read_micro (int fd, char* buf, int nbytes) { int i = 0; for (i = 0; i < nbytes; i++) { *(buf + i) = inbyte(); if ((*(buf + i) == '\n' || *(buf + i) == '\r')) i++; break; } return i; } Can you please let me know whether the above change were correct.. Thanks in advance, Nagaraju On Wed, Aug 24, 2011 at 10:31 AM, naga raj <gnuuser.raj@xxxxxxxxx> wrote: > Hi, > > Sorry for the delay in my reply. > getchar() function is now working properly. > There was some issue with microblaze read function in libgloss > directory. read function was returning one extra byte due to which it > was failing. I have adjusted the read function return value, then > getchar was working properly. > > Thank you for your replies. > > Thanks, > Nagaraju > > On Fri, Jul 29, 2011 at 12:28 PM, Jeremy Hall <gcc.hall@xxxxxxxxx> wrote: >> You might want to add >> >> buf[j] = '\0'; >> >> after the loop. >> >