Dear all,
I am new to qnx so kindly pardon me for my silly qns.
I am trying to display a value to a label using the following method
sprintf(cs, "%2.1f",s[i]);
sprintf(cd, "%2.1f",d[i]);
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);\
but is seems to crash the system
but when i used a static string like
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,“TEST”, 0);
it seems to be ok.
It seems that i can use sprintf to pass the variable over.
Can anyhow help me out???
thanks in advance
it seems that it is not due to sprintf but when i insert a loop into it
i am really puzzle why a loop will cause a crash
for (i=1;i<15;i++){
sprintf(cs, "%2.1f",s[i]);
sprintf(cd, "%2.1f",d[i]);
PtSetResource( ABW_Ptlbl_Speed, Pt_ARG_TEXT_STRING,cs, 0);
PtSetResource( ABW_Ptlbl_Dist, Pt_ARG_TEXT_STRING,cd, 0);
}
error is:
Process 446480 (AntiB_gNiNo_NB1207392159576) terminated SIGSEGV code=1 fltno=11 ip=0117e154 mapaddr=00101154. ref=00000014
While this doesn’t explain your problem, you might want to note that if your code was working, the first 14 time though the loop would accomplish nothing visible.
mario
April 8, 2008, 8:40pm
4
To add to Mitch’s comment, I find the i=1 odd typicaly it would be 0. Also how have you defined the cs and cd variables?
For the conversion in sprintf I would use ‘lf’ (LF) if the variable is defined as double, at waht point does it crash?