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

String format rules


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 12-30-2015 , 05:49   String format rules
Reply With Quote #1

Can somebody help? I need to trim string which's more than 10 chars? Thanks.
ZASTRELIS is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-30-2015 , 05:58   Re: String format rules
Reply With Quote #2

Do you want to truncate a string to the given length? If so, this should do:
PHP Code:
char myString[64] = "Some string you would like to truncate to 10 chars...";
myString[10] = '\0'
klippy is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 12-30-2015 , 07:06   Re: String format rules
Reply With Quote #3

any idea with trim?

Last edited by ZASTRELIS; 12-30-2015 at 07:06.
ZASTRELIS is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 12-30-2015 , 08:14   Re: String format rules
Reply With Quote #4

By trim you mean this trim?
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 12-30-2015 , 13:51   Re: String format rules
Reply With Quote #5

no.. I said about cropping string
ZASTRELIS is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 12-30-2015 , 14:44   Re: String format rules
Reply With Quote #6

Format(str, sizeof(str), "%.10s", otherstr), I guess? o.o your question isn't really clear
Miu is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 12-30-2015 , 18:00   Re: String format rules
Reply With Quote #7

Your question was already answered in the first reply.

PHP Code:
char myString[64] = "Some string you would like to truncate to 10 chars...";
PrintToChatAll(myString); // output: Some string you would like to truncate to 10 chars...
myString[10] = '\0';
PrintToChatAll(myString); //output: Some strin 
__________________
ddhoward is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 12-30-2015 , 18:44   Re: String format rules
Reply With Quote #8

Quote:
Originally Posted by ddhoward View Post
Your question was already answered in the first reply.
Yeah, but then he asked about "trim", so I was like "What the fu**?"... :-D
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 01-01-2016 , 13:28   Re: String format rules
Reply With Quote #9

Quote:
Originally Posted by ddhoward View Post
Your question was already answered in the first reply.

PHP Code:
char myString[64] = "Some string you would like to truncate to 10 chars...";
PrintToChatAll(myString); // output: Some string you would like to truncate to 10 chars...
myString[10] = '\0';
PrintToChatAll(myString); //output: Some strin 
Thanks. I use this method.
ZASTRELIS 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 05:44.


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