4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Declaring an array in C
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
kepler
Junior WebHelper
Junior WebHelper


Joined: 08 Feb 2002
Posts: 37

PostPosted: Tue Oct 19, 2004 1:18 pm (19 years, 6 months ago) Reply with QuoteBack to Top

Hi,

I'm trying to create a simple array in a C file. It goes something like this:

Code:

int NCON=89;
/*#define NCON 89*/
char *constel[89] = {
"And Andromedae",
(etc...)
"Vul Vulpeculae",
};


But when I call for constel[number] ( constel[7], for example) I get a null value. The same thing happens with another array I have:

Code:

/*#define NBNDRIES 357*/
int NBNDRIES = 357;
long bndries[4*357] = {
     0L,  86400L, 316800L,  84L,
 28800L,  52200L, 311400L,  84L,
(etc...)
     0L,  86400L, -324000L,  58L,
};


What am I doing so obviously wrong?

Regards,

Kepler


Last edited by kepler on Tue Oct 19, 2004 1:39 pm, edited 1 time in total
OfflineView User's ProfileFind all posts by keplerSend Personal Message
kepler
Junior WebHelper
Junior WebHelper


Joined: 08 Feb 2002
Posts: 37

PostPosted: Tue Oct 19, 2004 1:38 pm (19 years, 6 months ago) Reply with QuoteBack to Top

I removed the "*" from constel. Now I get the error: excess elements in char array initializer - but I've counted - it's correct.

Regards,

Kepler
OfflineView User's ProfileFind all posts by keplerSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Wed Oct 20, 2004 2:20 pm (19 years, 6 months ago) Reply with QuoteBack to Top

Code:
long bndries[4*357] = {

I don't think you can do mathematical operations there.

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 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.


Page generation time: 0.12549 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme