String to Integer - atoi does not work ?

19 Jan 2012

    if (cfg.getValue(key5, &value[0], sizeof(value))) {usbUART.printf("'%s'='%s'\n\r", key5, value);} //lcl_port
    
    lcl_port = atoi(key5); //Update udp port

    usbUART.printf("lcl_port = %d\n\r", lcl_port);

The first printf works, i get "44444"

The result of second = 0

What am i doing wrong?

Theo (nl)

19 Jan 2012

do you mean atoi of the key ? or did you mean to atoi the value ?

Not knowing what your key was.. would it atoi anyway ?

19 Jan 2012

Hi David,

Thanks for the hint. it indeed should have read:

lcl_port = atoi(value); //Update udp port

Theo (nl)