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

Removing the first X characters in a string


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mecha the Slag
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 02-20-2011 , 11:42   Removing the first X characters in a string
Reply With Quote #1

Hi.

How would I remove the first X characters in a string?

ie removing the first 5 characters from the string "abcdefghijk" would be "fghijk".

Thanks!
__________________
Mecha the Slag is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 02-20-2011 , 11:53   Re: Removing the first X characters in a string
Reply With Quote #2

Removes the first 3 characters:
Code:
new String:strExp[] = "abcdef";
strcopy(strExp, sizeof(strExp), strExp[3]);
__________________
pheadxdll is offline
Mecha the Slag
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 02-20-2011 , 12:41   Re: Removing the first X characters in a string
Reply With Quote #3

thanks pheadxdll!
__________________
Mecha the Slag is offline
Mecha the Slag
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 02-20-2011 , 12:47   Re: Removing the first X characters in a string
Reply With Quote #4

Okay it doesn't work at all.

This is what I attempted:

PHP Code:
RemoveFrontString(String:strInput[], iSizeiVar) {
    
strcopy(strInputiSizestrInput[iVar]);

__________________

Last edited by Mecha the Slag; 02-20-2011 at 12:51.
Mecha the Slag is offline
Zylius
SourceMod Donor
Join Date: Nov 2009
Old 02-20-2011 , 12:51   Re: Removing the first X characters in a string
Reply With Quote #5

Quote:
Originally Posted by Mecha the Slag View Post
Okay it doesn't work at all.

This is what I attempted:

PHP Code:
RemoveFrontString(String:strInputiSizeiVar) {
    
strcopy(strInputiSizestrInput[iVar]);

PHP Code:
RemoveFrontString(String:strInput[], iSizeiVar) {
    
strcopy(strInputiSizestrInput[iVar]);

>.< Ok, since you edited the post I don't know what's wrong

Last edited by Zylius; 02-20-2011 at 12:56.
Zylius is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 02-20-2011 , 13:02   Re: Removing the first X characters in a string
Reply With Quote #6

How exactly are you using it?
You don't have to actually remove the charactres if you just need to pass along the string.

Say you want to insert it in a format, you could just use the same method:
Format(Blah, sizeof(Blah), "Blah, short string: %s", sStringIWantFiveCharsDeep[5]);
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Mecha the Slag
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 02-21-2011 , 03:15   Re: Removing the first X characters in a string
Reply With Quote #7

actually nevermind, it seems to work just fine now :p
__________________
Mecha the Slag 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 10:13.


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