String constants

General discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

String constants

#1 Post by arco » 16 Nov 2012 12:33

Is it possible to create a string constant of 48 chars, with first char being '#' and remaining 47 chars being NULL chars?
(and what is the easiest way to do so if possible)
I need this to send to a GPRS modem.
Regards,

Peter.

gbtjom
Posts: 58
Joined: 13 Jan 2012 23:48

Re: String constants

#2 Post by gbtjom » 16 Nov 2012 21:38

This compiled for me for three characters:

const SEND as char[3] = (0x23,"","")

I think 0x23 is an "#" and "" is null. ???

jom

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: String constants

#3 Post by filip » 19 Nov 2012 14:15

Hi,

You could write something like this :

Code: Select all

const SEND as char[47] = (0x23)
Zeroth array member will be # and the rest the 46 characters will be padded with zeros in order to match declared array size of 47.

Regards,
Filip.

arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

Re: String constants

#4 Post by arco » 26 Nov 2012 23:51

Thanks,

I'll try that. I thought only the terminating character would be made 0x00, and the rest would be left undefined.
(I mean: Send[0] = 0x23, Send[1] = 0x00, and rest in undefined state...)
Regards,

Peter.

Post Reply

Return to “mikroBasic PRO for dsPIC30/33 and PIC24 General”