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

Solved Best way to set empty string


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hh2
AlliedModders Donor
Join Date: Sep 2010
Old 12-07-2016 , 10:53   Best way to set empty string
Reply With Quote #1

Code:
PHP Code:
char test[32];
Format(test32"test message");

1. Format(test32"");
2. StrCopy(test32"");
3. test[0] = 0;
4. test[0] = '\0';
5. test ""

Last edited by hh2; 12-09-2016 at 05:02.
hh2 is offline
milutinke
AlliedModders Donor
Join Date: Jun 2012
Location: Serbia
Old 12-07-2016 , 13:12   Re: Best way to set empty string
Reply With Quote #2

Code:
szString[ 0 ] = EOS;
milutinke is offline
Send a message via Skype™ to milutinke
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-07-2016 , 21:36   Re: Best way to set empty string
Reply With Quote #3

Quote:
Originally Posted by milutinke View Post
Code:
szString[ 0 ] = EOS;
PHP Code:
szString[0] = '\0'//All C/C++ api that deal with string assume index 0 being null term is an empty array (all null-term) when it may not be the case. SM uses C/C++ string system for plugin strings. 
__________________

Last edited by WildCard65; 12-07-2016 at 21:36.
WildCard65 is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 12-08-2016 , 02:30   Re: Best way to set empty string
Reply With Quote #4

Quote:
Originally Posted by milutinke View Post
Code:
szString[ 0 ] = EOS;
Check last post - https://forums.alliedmods.net/showthread.php?t=252489
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
hh2
AlliedModders Donor
Join Date: Sep 2010
Old 12-08-2016 , 17:37   Re: Best way to set empty string
Reply With Quote #5

Thanks for answers, i have last question about that:
is there difference between these?
PHP Code:
test[0] = 0;
test[0] = '\0'
hh2 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-08-2016 , 18:10   Re: Best way to set empty string
Reply With Quote #6

'\0' is equal to 0.
klippy is offline
hh2
AlliedModders Donor
Join Date: Sep 2010
Old 12-09-2016 , 05:02   Re: Best way to set empty string
Reply With Quote #7

Thanks for your help guys.
hh2 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 02:51.


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