CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Multi dimensional Arrays

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

Multi dimensional Arrays
PostPosted: Fri Jul 24, 2015 12:25 pm     Reply with quote

Hi all,

Is it possible to do string operations on Multidimensional arrays?

say:

Code:
strcat(Array1, Array2[1][]);


assume:

Code:
Array2[0][7]="abababa";
Array2[1][7]="cdcdcdc";


Something like that...


G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Fri Jul 24, 2015 11:47 pm     Reply with quote

Yes, and no....

Yes. Perfectly possible.

No, not with what you show.

A _string_ in C, is an array of characters _with a terminating null_.

The string "abababa", is eight characters long, not seven.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Sat Jul 25, 2015 7:40 am     Reply with quote

Hi,

I'm aware or the '\n' termination for strings...
I was just trying to convey my point quickly, not typing compilable pseudo.

I'm working on an IoT project which is working beautifully if i may say so, but id like to add more features by having a config.h file which holds the parts that change from one module to the other.

Rather than having a file with different GET/POST commands, i want to have a multidimensional array(string) and build the GETs on the fly...

It's a syntax question.... ive not seen on the manual how to feed <string.h> functions a multidimensional array.

Thanks.
G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Sat Jul 25, 2015 11:36 am     Reply with quote

Not '\n'. The terminator on a string is '\0'.

You don't. The string functions accept a pointer to a string. Nothing else.
The address of the first element in each row, points to that row. The row is just a string.

I have to say 'get a C text book'. This is nothing special in CCS, it is how C handles this. The manual assumes you have a C book or some understanding of C....
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Jul 26, 2015 6:50 am     Reply with quote

i think you can actually call a string operation on ANY location you set a pointer value to in memory, whether there is a string or not.

This is a strength and a weakness as CCS( and C in general )
has no bounds/dimension checking.

For all i know, you could even point to an SFR.

Just make sure there is a \0 terminator SOMEWHERE upstream before you pull the trigger Very Happy Very Happy Very Happy Very Happy
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Sun Jul 26, 2015 9:56 am     Reply with quote

... i was thinking "null" and typed '\n' because of the Letter N...
its a common mistake i make while programming.
anyways i came here for help, i guess its easier to be condescending.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group