Raised This Month: $ Target: $400
 0% 

[SOLVED] Check a variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cadav0r
Senior Member
Join Date: Jan 2006
Location: France
Old 04-13-2006 , 09:14   [SOLVED] Check a variable
Reply With Quote #1

Hello

I want to verify if a variable is empty or not

I try this but it doesn't work :
Code:
new reason[32]
if (!reason[32]) {
    ...
}
__________________
P.S : Sorry for my english but I'm French

My plugins : Admin Sounds




Cadav0r is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 04-13-2006 , 09:16  
Reply With Quote #2

if(!reason[0])

doing it your way it will see if the last character is 0 which will always be true.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Cadav0r
Senior Member
Join Date: Jan 2006
Location: France
Old 04-13-2006 , 09:46  
Reply With Quote #3

Huuummm

Ok thanks (+karma)
__________________
P.S : Sorry for my english but I'm French

My plugins : Admin Sounds




Cadav0r is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 04-13-2006 , 09:59  
Reply With Quote #4

In fact, doing it his way won't do that either because the last valid index in a 32-elements array is 31; so reason[32] will be either caught by the compiler (it should), or it will cause an out-of-bounds runtime error.

Suicid3 is right, if the first character (index 0) is zero, the string is empty.
__________________
hello, i am pm
PM is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 04-13-2006 , 10:02  
Reply With Quote #5

Hello PM[/code]
Code:
AM
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
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 05:05.


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