Problem with scanf() function

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problem with scanf() function

1,267件の閲覧回数
renjithvamanan
Contributor III

Hi,

 

I am working on a bare board project for TWR-K60 board. Console IO component is added from the Processor Expert.When I use scanf to read a string, I am missing the first character in the string. But with gets() I am able to read string without any issues. What could be the possible issue ?

 

Source code is as simple as

 

printf("Enter a String");
scanf("%s", str);
printf("\nString : %s", str);

 

Anybody had such a problem before ?

 

Best regards,

Renjith

ラベル(1)
0 件の賞賛
返信
1 返信

848件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

you use processor expert. ConsloeIO component is CPU External Devices-Display This component generates low-level methods for redirecting console I/O to the selected UART. These methods are typically used by printf()/scanf() methods. With Consloe component, printf and scanf are usable. If you don’t use prinf or scanf, you needn't consoleIO component. please refer the demo code under ..\MCU\CodeWarrior_Examples\Processor_Expert\Kinetis\TWR-K21D50M\Serial if the demo code can't help, please post your project here. we will check. thanks!

0 件の賞賛
返信