Raised This Month: $ Target: $400
 0% 

Split string


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-09-2017 , 21:22   Re: Split string
Reply With Quote #9

Quote:
Originally Posted by SpawnerF View Post
Code:
Strings should never be returned from functions especially general purpose functions.
What do you suggest then?
Strings should be passed as byref function parameters the same way that every AMX Mod X function that generates a string as its output. For example, get_user_name() takes the string array and the length as parameters.


Quote:
Originally Posted by SpawnerF View Post
Code:
I'm not sure what angle brackets do for creating an array but it's not wise to use extremely obscure features when providing support on these forums unless it's the only way to do it.
It's a macro replaced by the pre-processor, I add it because when I do charsmax(p_szOutput[]) I get an error saying "indeterminate array size" but nvm It's fixed I updated my code adding the size parameters using sizeof in Split func.
charsmax and sizeof are pre-processor functions so it is not possible to use them on arrays that don't have a determined size at compile time. Therefore, you can't use them on any variables in a function's prototype that doesn't have a defined size.

Given this, I don't know how your Split() function can actually work since you are using sizeof in the function's prototype. Not sure why it even compiles. If you need to know the dimensions of the arrays provided to the function, you'll need to pass those dimensions into the function as shown in the URL that you referenced.

Did you test your code?
__________________
fysiks is online now
 



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 22:49.


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