Hi,
is sprintf with more than one value supported? the following call seems to hang the microcontroller:
int i, j;
char buffer[128];
sprintf(buffer, "message: %d, %d", i, j);
sprintf with more than one value
Re: sprintf with more than one value
Hello,
Just Try this:
... and make sure that the string 'buffer' is null terminated...
regards!
Just Try this:
Code: Select all
int i, j;
char buffer[128];
sprintf("%s message: %d, %d", buffer, i, j);
regards!
Re: sprintf with more than one value
Hi,
according to the doc...
where...
your example has the destination and format strings in the opposite order... is that how is this library in mikroC supposed to work???
according to the doc...
Code: Select all
void sprintf(char *wh, const code char *f,...);
Code: Select all
wh: destination string
f: format string
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: sprintf with more than one value
Hello,
I used mikroC PRO for PIC2.40 and LV32MX v6 with PIC32MX460.
There is a sprintf example included in compiler, and you can test it.
Best regards.
I have successfully tested your code and it works like it should.bw64 wrote:Hi,
is sprintf with more than one value supported? the following call seems to hang the microcontroller:
int i, j;
char buffer[128];
sprintf(buffer, "message: %d, %d", i, j);
I used mikroC PRO for PIC2.40 and LV32MX v6 with PIC32MX460.
There is a sprintf example included in compiler, and you can test it.
Best regards.