Problem with scanf() function

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with scanf() function

886 Views
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

Labels (1)
0 Kudos
Reply
1 Reply

467 Views
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 Kudos
Reply