ARM Technical Support Knowledge Articles

SCANF() BEHAVES INCORRECTLY

Applies to: C51 C Compiler

Answer


Information in this article applies to:


SYMPTOMS

When I use scanf() in my program, I cannot enter any data. The function sometimes returns after entering one character and sometimes after two, but it never waits for Enter to be pressed, as it should. It always returns a value of zero and the variables passed to scanf() are never assigned values.

CAUSE

This is a bug in version 5.5 of the C51 compiler. See below for more information.

RESOLUTION

If you wish to enter lines of text, then the Measure example program demontrates how to do this by using the getkey() function. The code is self-contained and can be found in the getline.c source file.

A similar method can be used to enter values, either parsing the input as it is entered or by entering a string and calling atoi() to convert to an integer.

MORE INFORMATION

SEE ALSO

Article last edited on: 2004-06-08 10:50:50

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential