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 !
vrozos
Officer Cadet
Posts: 63
Joined: Mon Nov 21, 2011 12:36 pm
Location: Athens, Greece
Contact:

sprintf

Post by vrozos »

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 »

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: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: sprintf

Post by Dbug »

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