cancel
Showing results for 
Search instead for 
Did you mean: 

scanf() with whitespaces on STM32

Duy Tran
Associate II
Posted on July 13, 2018 at 05:12

Hello,

I am using the scanf with CubeMX 4.26, I want to read the input string with white spaces so I do something like this:

/* My variables here */

char console_input1[20];

char console_input2[20];

/* My code here */

printf('\r\nWhat is your name?\r\n>');

fflush(stdout);

scanf('%[^\r]s',console_input1);

printf('\r\nDo you like STM32?\r\n>');

fflush(stdout);

scanf('%[^\r]s',console_input2);

It works for the first input for entering my name, but for the second input that ask me if I like STM32, I can't reply or send characters:

What is your name?

>Duy Tran

Do you like STM32?

> /* I can't type in here */

Is there any solution for this? If I use scanf('%s', 

console_input1) and scanf('%s', 

console_input2) the program works fine but I can't insert whitespaces.

Thank you very much,

           Duy

#scanf()-stm32 #scanf()
0 REPLIES 0