Raised This Month: $12 Target: $400
 3% 

Initializing an array to -1s ??


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 08-15-2006 , 00:24   Initializing an array to -1s ??
Reply With Quote #1

Doing this:

Code:
    new iUserSkills[MAX_SKILLS] = {-1};     for ( i = 0; i < MAX_SKILLS; i++ )     {         server_print( "[DEBUG] [%d]: %d", i, iUserSkills[i] );     }

Says that at every position of iUserSkills, it is 0, not -1. I also tried a positive number like 700 and I received the same thing. How can I initialize the entire array to -1? Do I have to loop through it and set all values to -1?
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 08-15-2006 , 00:32   Re: Initializing an array to -1s ??
Reply With Quote #2

Code:
new iUserSkills[MAX_SKILLS] = {-1, ...};
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Smokey485
Senior Member
Join Date: Dec 2004
Location: Newt 'Ellin
Old 08-15-2006 , 02:08   Re: Initializing an array to -1s ??
Reply With Quote #3

Quote:
Originally Posted by teame06 View Post
Code:
new iUserSkills[MAX_SKILLS] = {-1, ...};
WOuld that do it make all the array's -1, or does the ... represent another -1, and another, and another...etc
__________________
+karma if I am helpful to you.
I am one in a few million.
Smokey485 is offline
Send a message via AIM to Smokey485 Send a message via MSN to Smokey485
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 08-15-2006 , 03:43   Re: Initializing an array to -1s ??
Reply With Quote #4

Quote:
Originally Posted by Smokey485 View Post
WOuld that do it make all the array's -1, or does the ... represent another -1, and another, and another...etc
the ... will fill the array with -1 because the value b4 is -1
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
Smokey485
Senior Member
Join Date: Dec 2004
Location: Newt 'Ellin
Old 08-15-2006 , 11:24   Re: Initializing an array to -1s ??
Reply With Quote #5

Quote:
Originally Posted by Greenberet View Post
the ... will fill the array with -1 because the value b4 is -1
So,ALL of them would be filled as -1?
__________________
+karma if I am helpful to you.
I am one in a few million.
Smokey485 is offline
Send a message via AIM to Smokey485 Send a message via MSN to Smokey485
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 08-15-2006 , 11:26   Re: Initializing an array to -1s ??
Reply With Quote #6

exactly
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 08-15-2006 , 13:20   Re: Initializing an array to -1s ??
Reply With Quote #7

I see! I've always wonder what's those 3 periods are for.
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:02.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode