Raised This Month: $ Target: $400
 0% 

Max characters of a string.


Post New Thread Reply   
 
Thread Tools Display Modes
Decak
Senior Member
Join Date: Sep 2012
Old 04-03-2015 , 18:12   Re: Max characters of a string.
Reply With Quote #11

Code?
Decak is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-03-2015 , 19:43   Re: Max characters of a string.
Reply With Quote #12

Quote:
Originally Posted by Andu. View Post
I understood it but my string is read because is "register_clcmd("say","HookClCmdSay");" and i can't use szChat[] i can only use szChat
That is wrong. All strings are arrays of characters. You can access each individual character by indexing the array. Therefore, you can compare individual characters. So, to check for a period, you can do this:

Code:
if( szChat[x] == '.' )
Notice the use of single quotes. This means character (an integer) instead of string (array of integers).

So, you've got all you need from us. If you want more help you are going to need to either show the code that you tried on your own or explain better what you want.
__________________
fysiks is offline
Andu.
Member
Join Date: Oct 2013
Location: Belgravistan
Old 04-04-2015 , 04:07   Re: Max characters of a string.
Reply With Quote #13

Thank you so much fysiks , i used this :
if(!equal(szChat[strlen(szChat)-1],"."))
szChat[strlen(szChat)] = '.'
Thank you all.
Andu. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-04-2015 , 12:58   Re: Max characters of a string.
Reply With Quote #14

Quote:
Originally Posted by Andu. View Post
Thank you so much fysiks , i used this :
if(!equal(szChat[strlen(szChat)-1],"."))
szChat[strlen(szChat)] = '.'
Thank you all.
You need to also set the EOS again after the period otherwise it will break the string. This is also why you need to verify that the string variable (array) is big enough to contain that extra character.
__________________
fysiks 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 20:48.


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