set_char

( <-- Back to Sporkl Function Library )


void set_char ( string str, int index, string char )


Sets a selected character in a string.



Arguments:

str:
index:
char:
String in which to set a character
Index of the character to set - if string is of length n, then this value may range from [0-(n-1)]
Value to set index'th character in s to. Must be specified as a string of length 1.

Returns:

Nothing.

Example:

The code:

string s = "Hello World.";

set_char(s,0,"J");
set_char(s,4,"y");
set_char(s,length(s)-1,"!");

print(s + "\n");

produces the following output:

Jelly World!









sporkforge