Skip to content

Possible incompatibility with sprintf #5

Description

@AlexanderKokushkin

Hello! Thank you for your excellent library!

I slightly modified your example to highlight this strange behaviour:
sprintf( tmpString, "foo.a=%02d" , foo.a ); prints 26350 instead of 45
meanwhile
sprintf( tmpString, "foo.a=%02d" , uint8_t(foo.a) ); works well

=============================================

#include <EEPROM.h>
#include <EEWrap.h>

//Use the xxx_e types rather than the standard types like uint8_t
struct Foo{
uint8_e a;
int16_e b;
float_e c;
};

Foo foo EEMEM; //EEMEM tells the compiler that the object resides in the EEPROM

void setup(){

//Write to values stored in EEPROM
foo.a = 45;
foo.b = 12345;
foo.c = 3.1415;

//Print values from EEPROM
Serial.begin(9600);
Serial.println(foo.a);
Serial.println(foo.b);
Serial.println(foo.c);

char tmpString[20] = {0};
sprintf( tmpString, "foo.a=%02d" , foo.a );
Serial.println( tmpString ); // it prints " foo.a=26350 "
}

void loop() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions