Problem with scanf() function

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem with scanf() function

951 次查看
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 回复

532 次查看
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 项奖励
回复