Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #102732

Re: Finding the position of a character in a string.

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Ike Naar <ike@iceland.freeshell.org>
Newsgroups comp.lang.c
Subject Re: Finding the position of a character in a string.
Date Sun, 29 Jan 2017 21:49:55 -0000 (UTC)
Organization A noiseless patient Spider
Lines 8
Message-ID <slrn3vfso8sov8.jam.ike@iceland.freeshell.org> (permalink)
References <432459d7-dc1c-4c69-a197-3767764ddd7a@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Injection-Date Sun, 29 Jan 2017 21:49:55 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="e13b237512493c45f9aa7d1f131d30bd"; logging-data="32474"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+RReIEaEcyC0F4ESyZB7IO"
User-Agent slrn/0.9.9p1 (NetBSD)
Cancel-Lock sha1:/eZ6gcUkTs1qu+QgG7LAc9cC768=
Xref csiph.com comp.lang.c:102732

Show key headers only | View raw


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 ?

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

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

csiph-web