sprintf

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
Post Reply
vrozos
Officer Cadet
Posts: 63
Joined: Mon Nov 21, 2011 12:36 pm
Location: Athens, Greece
Contact:

sprintf

Post by vrozos » Sun Nov 04, 2012 9:58 pm

I think there is a problem with sprintf.

int le=1;
char strng[40];

sprintf(strng, "%d", le);
printf("LE=%d LE=%s\n", le, strng);

I get
LE=1 LE=15

V.

vrozos
Officer Cadet
Posts: 63
Joined: Mon Nov 21, 2011 12:36 pm
Location: Athens, Greece
Contact:

Re: sprintf

Post by vrozos » Sun Nov 04, 2012 10:13 pm

I think OSDK sprintf puts the null-terminator always at position 4 even if the integer has only 1 digit.

V.

User avatar
Dbug
Site Admin
Posts: 2322
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: sprintf

Post by Dbug » Sun Nov 04, 2012 11:17 pm

The complete code of the osdk is in the /lib folder, sprintf is implemented in "printf.s" but also rely on conversions from "itoa" and other functions.
Possibly the issue is in itoa.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest