Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #102715 > unrolled thread
| Started by | janus <emekamicro@gmail.com> |
|---|---|
| First post | 2017-01-29 10:10 -0800 |
| Last post | 2017-01-29 21:49 +0000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.c
Finding the position of a character in a string. janus <emekamicro@gmail.com> - 2017-01-29 10:10 -0800
Re: Finding the position of a character in a string. fir <profesor.fir@gmail.com> - 2017-01-29 10:27 -0800
Re: Finding the position of a character in a string. Chad <cdalten@gmail.com> - 2017-01-29 12:07 -0800
Re: Finding the position of a character in a string. Ike Naar <ike@iceland.freeshell.org> - 2017-01-29 21:49 +0000
| From | janus <emekamicro@gmail.com> |
|---|---|
| Date | 2017-01-29 10:10 -0800 |
| Subject | Finding the position of a character in a string. |
| Message-ID | <432459d7-dc1c-4c69-a197-3767764ddd7a@googlegroups.com> |
Hello All, Is there a standard function for finding character index Or a better way that what I have below? char *sop = "+-*/()=,.#<>[];"; char *chpos = strchr(sop, ch); int idx = chpos == NULL ? -1 : chpos - sop; Regards, Janus
[toc] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2017-01-29 10:27 -0800 |
| Message-ID | <6c9f7701-3ed0-4797-a629-8907a1e6affd@googlegroups.com> |
| In reply to | #102715 |
W dniu niedziela, 29 stycznia 2017 19:11:03 UTC+1 użytkownik janus napisał: > Hello All, > > Is there a standard function for finding character index Or a better way that what I have below? > > char *sop = "+-*/()=,.#<>[];"; > char *chpos = strchr(sop, ch); > int idx = chpos == NULL ? -1 : chpos - sop; > im not a fan of this kind simple standard functions, write yourself one and done main reason is that say standard external reference is better then nonstandard reference, but no external reference is best to me (of those mentioned) you could also craft such functions more coherent to your style etc (one could mention though that i voted for max/min being in stdlib but that was purely intrinsical one and such should be supported (more by compiler than external lib) some could also say that such functions could be intrinsinked and well optimised but except hotspots it dont quite matter (i also doubt if they would be really well optimised, in many cases back in history it showed to be weak with that) [i would very like (as i said) to get rid of all clib references (except sane intrinsics) in my framework but im just to lazy for that at the moment]
[toc] | [prev] | [next] | [standalone]
| From | Chad <cdalten@gmail.com> |
|---|---|
| Date | 2017-01-29 12:07 -0800 |
| Message-ID | <f799a6a1-cbb2-435d-b642-d1e5897f4026@googlegroups.com> |
| In reply to | #102718 |
Yes. Read Knuth.
[toc] | [prev] | [next] | [standalone]
| From | Ike Naar <ike@iceland.freeshell.org> |
|---|---|
| Date | 2017-01-29 21:49 +0000 |
| Message-ID | <slrn3vfso8sov8.jam.ike@iceland.freeshell.org> |
| In reply to | #102715 |
On 2017-01-29, janus <emekamicro@gmail.com> wrote: > Is there a standard function for finding character index Or a better way that what I have below? > > char *sop = "+-*/()=,.#<>[];"; > char *chpos = strchr(sop, ch); > int idx = chpos == NULL ? -1 : chpos - sop; strspn / strcspn ?
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web