This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: microblaze getchar() not functioning properly


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@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]