Re: microblaze getchar() not functioning properly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/28/2011 04:30 AM, naga raj wrote:

I have observed following output:

  main
  input value of i is:a           ---------->my input ( I have not
pressed any key after entering 'a')
  value of j is:0
  input value of i is:             ------------->  It is automatically
skipping to take my input
  value of j is:1

You get better info if you print values in hex, rather than character.
How would you know that the extra character is a null and not a CR or LF?

I have given the input to the program using HyperTerminal. I have
entered only abc as my input.

Why do you think that this is a problem in getchar()?

With the above observation I am thinking that getchar() function is
appending a null character after each character.

I think that it is extremely unlikely that buffered input, which
getchar() uses, is inserting extra characters into the input stream.

You need to be careful using a terminal emulator (whether Hyperterminal,
minicom, or any other).  There are lots of problems when buffered input
and output are interspersed.  Check your configuration.

You can use GDB, as Jeff suggests, to step through getc() (which getchar()
calls) and see what actually is received from the terminal emulator.


--
Michael Eager	 eager@xxxxxxxxxxxx
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux