This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

sprintf ()

Hello!

Some time ago I had a problem with sprintf(), it just didn't change the string variable as it should have. The problem somehow vanished, and I had no time to investigate further...

Now I have the same problem again, here's a snippet:

char xdata c [80];
strcpy (c, "Text"); 
sprintf (c, "%s", "Text2");
The strcpy command works fine, the content of c is "Text" after execution.
The sprintf command (also any other variation of sprintf, no matter if %d, %c, %s, etc) does not change the contents of c.
The memory model is LARGE.

Now, here comes a weird detail: also in xdata, I have a large array. If I make this array smaller, the sprintf command works again.
Does maybe sprintf itself "need" memory in xdata, which it maybe cannot allocate anymore because there's no space?
The only thing I change to make it work is to use less xdata memory.

I don't get any error messages from compiler or linker.

Thank you for any help!
Holger

Parents
  • sprintf() will certainly need some memory for its "locals," and where it needs this memory is defined by the memory model - LARGE will need space in XDATA.

    Could you have problems with you overlaying? Check the map file.

    Are you using function pointers, or any other "cunning tricks" where concurrent calls may not be evident to the linker?

Reply
  • sprintf() will certainly need some memory for its "locals," and where it needs this memory is defined by the memory model - LARGE will need space in XDATA.

    Could you have problems with you overlaying? Check the map file.

    Are you using function pointers, or any other "cunning tricks" where concurrent calls may not be evident to the linker?

Children
No data