scanf doesn't seem to be working

25 Sep 2012

Hi,

I was trying some stuff out with scanf and tried the code here.

The latest version I'm using is, but it only outputs n = 0, r = 0:

#include "mbed.h"

DigitalOut myled(LED1);
Serial usb(USBTX, USBRX);
Serial s(p9, p10);

int main() {
    myled=1;
    s.printf("R125\0");
    int r;
    int n = s.scanf("R%3d\0", &r);
    printf("n = %d, r = %d\n\r", n, r);
}