# Traces & pointers to string

**URL:** <https://forum.sierrawireless.com/t/traces-pointers-to-string/4422>\
**Category:** Open AT\
**Created:** [May 10, 2010, 9:59am UTC](https://forum.sierrawireless.com/t/traces-pointers-to-string/4422 "2010-05-10T09:59:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomb](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@tomb](https://forum.sierrawireless.com/u/tomb)\
**Post date:** [May 10, 2010, 9:59am UTC](https://forum.sierrawireless.com/t/traces-pointers-to-string/4422/1 "2010-05-10T09:59:05Z")

</div>

Hi,  
Can somone tell me why this doesn’t work:

```auto
TRACE (( 1, ">>>SMS_PHONE_NUM: %s", SmsTel));
    TRACE (( 1, ">>>SMS_TEXT: %s", SmsText));
```

I received wrong data:

```auto
Trace	CUS3	1	>>>SMS_PHONE_NUM: 
Trace	CUS3	1	>>>SMS_TEXT: ‹¬$
```

Cheers,  
Tom

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [May 10, 2010, 10:14am UTC](https://forum.sierrawireless.com/t/traces-pointers-to-string/4422/2 "2010-05-10T10:14:10Z")

</div>

Check the ADL User Guide carefully - what does it say about the use of %s… ❓

---

<div class="post-metadata">

**Author:** ![tomb](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@tomb](https://forum.sierrawireless.com/u/tomb)\
**Post date:** [May 11, 2010, 6:42am UTC](https://forum.sierrawireless.com/t/traces-pointers-to-string/4422/3 "2010-05-11T06:42:34Z")

</div>

OK, found it:

> [@](#):
>
> ‘%s’ character, normally used to insert strings, is not supported by the trace  
> function.

Thanks

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [May 11, 2010, 7:08am UTC](https://forum.sierrawireless.com/t/traces-pointers-to-string/4422/4 "2010-05-11T07:08:13Z")

</div>

You got it!

If you need formatted output with “variable” strings, you have to sprintf to a buffer first, and then TRACE the buffer…

eg,

```auto
sprintf( my_trace_buffer, ">>>SMS_PHONE_NUM: %s", SmsTel );
TRACE(( 1, my_trace_buffer ));
```

---

<div class="post-metadata">

**Author:** ![Madouc](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Madouc](https://forum.sierrawireless.com/u/Madouc)\
**Post date:** [May 11, 2010, 3:19pm UTC](https://forum.sierrawireless.com/t/traces-pointers-to-string/4422/5 "2010-05-11T15:19:01Z")

</div>

> [@awneil](#):
>
> If you need formatted output with “variable” strings, you have to sprintf to a buffer first, and then TRACE the buffer…

also keep in mind that printing floats has an issue when using GCC

---

<div class="post-metadata">

**Author:** ![raveesa](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@raveesa](https://forum.sierrawireless.com/u/raveesa)\
**Post date:** [June 10, 2010, 4:00am UTC](https://forum.sierrawireless.com/t/traces-pointers-to-string/4422/6 "2010-06-10T04:00:46Z")

</div>

Hi,  
i’m using q2686 wavecom module.  
There is some problem at the sprintf ie the device is getting restarted after executing the sprintf line.  
the below is the code which i have written .

char \* Src\_buff;float Temp1=24.3,Temp2=34; int tilt=3,busv=6;  
sprintf( Src\_buff,“Download from SL100876, Genaral CONSULTANCY , on 07/05/2010 at 16:10:02\n date time , FFA1TS, FFA2TI, FFA3BA, FFA4TA,\ndd/mm/yy hh:mm:ss, 1 ?C, 3 Angle, 5 V,6 K,\n07/06/10 15:30:00, %f, %d, %d, %f,”, Temp1,tilt,busv,Temp2);

but if use it in simple way it wont get restarted ie sprintf( Src\_buff,“checking the sprintf”);

what may be the problem , why its getting restarted …?  
pls help me…

regards  
chethan

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.sierrawireless.com/u/davidc)\
**Post date:** [June 10, 2010, 5:59am UTC](https://forum.sierrawireless.com/t/traces-pointers-to-string/4422/7 "2010-06-10T05:59:01Z")

</div>

Hiya,

> [@chethankpc](#):
>
> sprintf( Src\_buff,“Download from SL100876, Genaral CONSULTANCY , on 07/05/2010 at 16:10:02\n date time , FFA1TS, FFA2TI, FFA3BA, FFA4TA,\ndd/mm/yy hh:mm:ss, 1 ?C, 3 Angle, 5 V,6 K,\n07/06/10 15:30:00, %f, %d, %d, %f,”, Temp1,tilt,busv,Temp2);

Did you see the comment above about using %f when using the GCC compiler?

There’s a note in the ADL guide about this too…

ciao, Dave
