Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Char array?

Author
Message
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 13th Jul 2008 22:25
Can I make an array which contains diffrent char values? Like this:

char[0] = "Zero"
char[1] = "One"
char[2] = "Two"
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 13th Jul 2008 22:34 Edited at: 13th Jul 2008 22:35
I assume you mean an array of strings. If you simply want an array of string constants:



Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 13th Jul 2008 22:50
char[0] = "H"
char[1] = "i"
char[2] = "."

That's allowed. But, like Benjamin said, it will have to be an array of char* to use more than one character.
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 14th Jul 2008 20:38 Edited at: 14th Jul 2008 20:39
But how should I do if I whant to add more values later?

I only get errors when I try:

stringArray[3] = "something";
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 14th Jul 2008 20:44
You have to declare it like so:

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 14th Jul 2008 20:52 Edited at: 14th Jul 2008 20:52
You can declare enough for your future needs by increasing the number inside the [] pair. You don't have to populate all of them at the time of the declaration so you have a bit of space to expand into.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 17th Jul 2008 20:58
Okey, thanks!

Login to post a reply

Server time is: 2024-11-20 17:29:14
Your offset time is: 2024-11-20 17:29:14