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() problem.

Hi!

Can you please tell me what is wrong in here:

/* An example from Cx51 userÂ's guide */

#include<stdio.h>
#include<float.h>

void main(void)
{
code char buf[100];
int n;
int a,b;
float pi;

a = 123;
b = 456;
pi = 3.14159;
n = sprintf(buf, "%f", 1.1);
}

It builds fine but when I start debugging the program throws me into disassembly window after first step. And nothing happens.

I need the sprintf function in my own project, and obviously, it doesnÂ't work in it. so I tried it in this simpler code and it doesnÂ't work here either.

Regards
Aki

Parents
  • Problem was/is that after I inserted sprintf function in the code I found myself in dissassembly window after first step.

    
    #pragma SYMBOLS
    
    #include<AT898252.h>
    #include<stdlib.h>
    #include<float.h>
    #include<stdio.h>
    
    Init();
    char tulos[32];
    
    void main()
    {
        sprintf(tulos,"%f",20.0);
    
        Init();
    }
    
    Init()
    {
    ...
    }
    

    Code was basically like that. I noticed that sprintf consumes more than 2k of space! Is the answer to my problem that I overlap the evaluation versions 2k code size limit?

Reply
  • Problem was/is that after I inserted sprintf function in the code I found myself in dissassembly window after first step.

    
    #pragma SYMBOLS
    
    #include<AT898252.h>
    #include<stdlib.h>
    #include<float.h>
    #include<stdio.h>
    
    Init();
    char tulos[32];
    
    void main()
    {
        sprintf(tulos,"%f",20.0);
    
        Init();
    }
    
    Init()
    {
    ...
    }
    

    Code was basically like that. I noticed that sprintf consumes more than 2k of space! Is the answer to my problem that I overlap the evaluation versions 2k code size limit?

Children