11 years, 9 months ago.

How can I get scanf to echo input value

Hi,

I am not able to get scanf to echo an interger value as I read from mbed.

I have tried the code on a PC and it does what I expect.

#include "mbed.h"    
       
Serial pc(USBTX, USBRX); // tx, rx
 
int main() {
   int x;
   pc.printf("Hello World!\n\r");
   pc.printf("Enter a value for X");
   pc.scanf("%i",&x);
   pc.printf("\n\rX = %i", x);
}

I am using Hyperterminal on my PC.

Is this a problem with mbed or hyperterminal?

Can you help?

Regards

Frank

1 Answer

9 years ago.

Hi Frank,

Did you ever solve this issue? I'm having the same problem with both scanf and gets :-(

Thanks, Aram