How can I define array of structure?

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
serkansatuk
Posts: 38
Joined: 31 May 2012 07:05

How can I define array of structure?

#1 Post by serkansatuk » 12 Jan 2015 15:06

Hi,
I would like to define an array of structure.
I would like to use structure like in the picture.
Compiler gives an error like this.
Could you help me please?
Attachments
structerror.JPG
structerror.JPG (41.63 KiB) Viewed 1926 times

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

Re: How can I define array of structure?

#2 Post by filip » 13 Jan 2015 14:28

Hi,

Consider this example :

Code: Select all

typedef struct{
  char first[10];
  char second;
  float third;
  float fourth;
} structure;

structure array[10];

void main() {
  array[1].fourth = 15.254;
}
Regards,
Filip.

serkansatuk
Posts: 38
Joined: 31 May 2012 07:05

Re: How can I define array of structure?

#3 Post by serkansatuk » 13 Jan 2015 15:41

thank you very much for your interest filip.
I forgot to write it in main routine.

serkansatuk
Posts: 38
Joined: 31 May 2012 07:05

Re: How can I define array of structure?

#4 Post by serkansatuk » 13 Jan 2015 16:03

i have too much data to store.

if i define structure like this, it gives RAM error.

if I define structure as const, it gives "Unresolved extern 'array' error.

Could you help me please?
Attachments
structerror2.JPG
structerror2.JPG (47.31 KiB) Viewed 1899 times
structerror1.JPG
structerror1.JPG (45.83 KiB) Viewed 1899 times

Sy
Posts: 708
Joined: 10 Dec 2009 13:41
Location: UK

Re: How can I define array of structure?

#5 Post by Sy » 14 Jan 2015 08:49

Couple of things...I wouldn't use terms like array or structure, these aren't good names, use a more descriptive name. Also arrays in C always start from 0, not sure if 1 is your intended first item or not?
Kind Regards,
Sy

Post Reply

Return to “mikroC PRO for PIC General”