# String function Problems

**URL:** <https://forum.sierrawireless.com/t/string-function-problems/3456>\
**Category:** Open AT\
**Created:** [July 17, 2009, 11:53pm UTC](https://forum.sierrawireless.com/t/string-function-problems/3456 "2009-07-17T23:53:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MLCarter](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@MLCarter](https://forum.sierrawireless.com/u/MLCarter)\
**Post date:** [July 17, 2009, 11:53pm UTC](https://forum.sierrawireless.com/t/string-function-problems/3456/1 "2009-07-17T23:53:35Z")

</div>

Hello,  
I’m getting there with my C++ but just having problems cutting characters of an array.

```auto
static ascii gpsbuff [DATA_MAX];//global
 
//local
u8 i,j,field,startp,len;
ascii temp15[15];

temp15==strncpy(&gpsbuff[startp],temp15,len);
temp15==strcat(temp15,"\r\n");
adl_atSendResponse ( ADL_AT_UNS, temp15 );
```

output should be;  
0  
00  
99.9  
I get  
9  
9  
9  
9  
I have to say I’m not clear on where to use the variable and where to use a pointer in these functions  
Help Please

---

<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:** [July 18, 2009, 7:48am UTC](https://forum.sierrawireless.com/t/string-function-problems/3456/2 "2009-07-18T07:48:26Z")

</div>

> [@MLCarter](#):
>
> I’m getting there with my C++

Actually, what you’ve shown is all just good ol’ C - it hasn’t strayed into any C++ territory (yet)…

> [@](#):
>
> I have to say I’m not clear on where to use the variable and where to use a pointer

For that, you need a ‘C’ textbook!

You could start with [publications.gbdirect.co.uk/c\_book/](http://publications.gbdirect.co.uk/c_book/)

Note that a pointer is a variable - the value of a pointer variable is the address of something and, because it’s a variable, you can change that value at run time; ie, you can assign a new value to it.

The name of an array acts, in many ways, like a pointer - because it gives the address of the 1st element of the array - but the key difference is that you cannot assign a value to it. Its value is fixed at build time.

Also note that “==” is not the assignment operator in ‘C’ !

The “==” double-equals is a comparison operator that checks if its two operands are equal!

Thus this code contains two mistakes:

```auto
temp15==strncpy(&gpsbuff[startp],temp15,len); // This is not an assignment, and would be illegal as an assignment!
```

1. You are trying to assign to an array name - which is not allowed;
2. You are using the equality comparison operator (==) instead of the assignment operator (=)

---

<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:** [July 18, 2009, 7:53am UTC](https://forum.sierrawireless.com/t/string-function-problems/3456/3 "2009-07-18T07:53:29Z")

</div>

```auto
temp15 == strncpy( &gpsbuff[startp], temp15, len );
```

Once you’ve corrected the errors noted above, I think you also need to check carefully that you have the parameters to strncpy in the correct order for your required result…

BTW: a little whitespace goes a long way in making code more readable…

---

<div class="post-metadata">

**Author:** ![MLCarter](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@MLCarter](https://forum.sierrawireless.com/u/MLCarter)\
**Post date:** [July 18, 2009, 11:00pm UTC](https://forum.sierrawireless.com/t/string-function-problems/3456/4 "2009-07-18T23:00:40Z")

</div>

Thanks for the help. yes 😊 on the ==  
I’m still struggling with basics, can’t find things in the documentation.  
Please for definations

what is a s32? I asummed it was a 32bit single but it looks like 32 bit integer??

for single/double precision numbers it should be

float number;  
double number;

Also how do you TRACE output a floating point numbers? It seems that the standard %f is not available, %d should give 1 decimal place?

number=9.98;  
TRACE((1,“number %d”,number));  
gives  
Number 1076098498

One more how do convert string to float? e.g temp15=“9.98”

---

<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:** [July 18, 2009, 11:35pm UTC](https://forum.sierrawireless.com/t/string-function-problems/3456/5 "2009-07-18T23:35:51Z")

</div>

> [@MLCarter](#):
>
> I’m still struggling with basics

It isn’t the place of the Wavecom documentation to teach you the ‘C’ language - it is assumed that you are already a competent ‘C’ programmer.

> [@](#):
>
> what is a s32? I asummed it was a 32bit single but it looks like 32 bit integer??

Yes, it is a signed 32-bit integer

And u32 is an unsigned 32-bit integer.

Similarly for u16/s16 and u8/s8

But you’re right - they are not documented 😠  
I guess they used to be documented in the so-called “Basic (sic) Development Guide” - now discontinued - and Wavecom forgot to put them into the ADL User Guide when the Basic guide was discontinued… 😒  
See: [viewtopic.php?f=3&t=3692&p=14287#p14284](http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?f=3&t=3692&p=14287#p14284)

But you can see the definitions in wm\_types.h

> [@](#):
>
> Also how do you TRACE output a floating point numbers? It seems that the standard %f is not available

The problem with %f is documented - and a workaround is given.

> [@](#):
>
> %d should give 1 decimal place?

No - %d gives an integer (‘C’ textbook again)
