AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Replace first character in a string (https://forums.alliedmods.net/showthread.php?t=309093)

BaD CopY 07-13-2018 19:38

Replace first character in a string
 
I need function who will replace first character in a string with new value for that character.

maqi 07-13-2018 20:06

Re: Replace first character in a string
 
Elaborate.

fysiks 07-13-2018 22:45

Re: Replace first character in a string
 
Code:

szString[0] = 'a'

BaD CopY 07-20-2018 11:35

Re: Replace first character in a string
 
I want hardcoded values for each character and function to replace first character with hardcoded value for that character

replaceWith[][] = {"a", "A"}

string = abc

function should return 'Abc'

Relaxing 07-20-2018 11:49

Re: Replace first character in a string
 
https://www.amxmodx.org/api/string/ucfirst

BaD CopY 07-20-2018 12:05

Re: Replace first character in a string
 
Thank you but uppercase was just an example.. mby I want to replace first character with a string

Relaxing 07-20-2018 13:50

Re: Replace first character in a string
 
Quote:

Originally Posted by BaD CopY (Post 2605095)
Thank you but uppercase was just an example.. mby I want to replace first character with a string

If you want to change the first char of a string then follow fyskis way.

fysiks 07-20-2018 21:20

Re: Replace first character in a string
 
Quote:

Originally Posted by BaD CopY (Post 2605095)
Thank you but uppercase was just an example.. mby I want to replace first character with a string

Is this new string going to be a single character or more than one character? If it's always only 1 character, do what I said.

edon1337 07-21-2018 06:02

Re: Replace first character in a string
 
Quote:

Originally Posted by BaD CopY (Post 2605086)
replaceWith[][] = {"a", "A"}

string = abc

function should return 'Abc'

So why 'Abc' instead of 'abc' when replaceWith has both 'a' and 'A' values?

fysiks 07-21-2018 13:48

Re: Replace first character in a string
 
Quote:

Originally Posted by edon1337 (Post 2605229)
So why 'Abc' instead of 'abc' when replaceWith has both 'a' and 'A' values?

Presumably that is the before and after characters.


All times are GMT -4. The time now is 03:13.

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