str_setchr (STRING* string, var char, var pos)
str_getchr (STRING* string, var pos)
Sets resp. returns the ASCII character value at a certain position in a string. The ASCII values correspond to characters according to the following table:
Char ASCII| Char ASCII| Char ASCII
-----------------------------------
Space 32 | @ 64 | ` 96
! 33 | A 65 | a 97
" 34 | B 66 | b 98
# 35 | C 67 | c 99
$ 36 | D 68 | d 100
% 37 | E 69 | e 101
& 38 | F 70 | f 102
' 39 | G 71 | g 103
( 40 | H 72 | h 104
) 41 | I 73 | i 105
* 42 | J 74 | j 106
+ 43 | K 75 | k 107
, 44 | L 76 | l 108
- 45 | M 77 | m 109
. 46 | N 78 | n 110
/ 47 | O 79 | o 111
0 48 | P 80 | p 112
1 49 | Q 81 | q 113
2 50 | R 82 | r 114
3 51 | S 83 | s 115
4 52 | T 84 | t 116
5 53 | U 85 | u 117
6 54 | V 86 | v 118
7 55 | W 87 | w 119
8 56 | X 88 | x 120
9 57 | Y 89 | y 121
: 58 | Z 90 | z 122
; 59 | [ 91 | { 123
< 60 | \ 92 | | 124
= 61 | ] 93 | } 125
> 62 | ^ 94 | ~ 126
? 63 | _ 95 | Cursor 127
Parameters:
string |
String pointer. |
char |
ASCII value - see table. It can be alternatively given in lite-C as a letter in single quotes (e.g. 'A' for 65). |
pos |
Position in the string, starting with 1 for the first character. |
Returns:
char - ASCII value at the given position in the string, or 0 when the position is outside the string.
Speed:
FastExample:
STRING* s = "ABC";
...
str_setchr(s,'X',1); // now s == "XBC"
See also:
STRING, str_to_num,
str_for_num, str_chr, strio.c
► latest
version online