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


Groups > comp.lang.c > #100096

Re: C newb - Part III - find a .jhr file in a directory - seg fault

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: C newb - Part III - find a .jhr file in a directory - seg fault
Date Fri, 23 Dec 2016 14:13:25 -0800
Organization None to speak of
Lines 27
Message-ID <lnbmw2b8fu.fsf@kst-u.example.com> (permalink)
References <azB3A.89805$dL2.72348@fx12.iad> <o3jnfl$n11$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx02.eternal-september.org; posting-host="df4a13e992574b38b1b7cd38c2b29037"; logging-data="15409"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187k2k67tcka001LgC2JEk5"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:uPgdIaCK7Psa65K6oFjxIgsyIm4= sha1:oWT82nuuRm0pg2MewkR2w0TEfcY=
Xref csiph.com comp.lang.c:100096

Show key headers only | View raw


BartC <bc@freeuk.com> writes:
> On 12/12/2016 17:58, S390 wrote:
>> finding all *.jhr in a directory
>
>>     while ((dir = readdir(d)) != NULL)
>>     {
>>      ret = strchr(dir->d_name, ch);
>>      printf("String after |%c| is - |%s|\n", ch, ret);
>>
>>       //if (strcmp(dir->d_name,"TESTJAMNNTPD.jhr") == 0) //
>
>
> Have a look at the 'fnmatch()' function which will do wildcard matching 
> for you. Something like:
>
>     if (fnmatch("*.jhr", dir->d_name, 0)) ...
>
> 'man fnmatch' for further details.

Be aware that fnmatch() is defined by POSIX, not by ISO C, and it might
not be available on all systems.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


Thread

C newb - Part III - find a .jhr file in a directory - seg fault S390 <s390@tampascanner.info> - 2016-12-12 17:58 +0000
  Re: C newb - Part III - find a .jhr file in a directory - seg fault Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-12 22:18 +0000
    Re: C newb - Part III - find a .jhr file in a directory - seg fault S390 <s390@tampascanner.info> - 2016-12-20 22:12 +0000
      Re: C newb - Part III - find a .jhr file in a directory - seg fault Barry Schwarz <schwarzb@dqel.com> - 2016-12-20 14:38 -0800
        Re: C newb - Part III - find a .jhr file in a directory - seg fault S390 <s390@tampascanner.info> - 2016-12-23 16:08 +0000
          Re: C newb - Part III - find a .jhr file in a directory - seg fault Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-23 16:34 +0000
          Re: C newb - Part III - find a .jhr file in a directory - seg fault "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-03 16:16 -0500
  Re: C newb - Part III - find a .jhr file in a directory - seg fault Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-12-23 12:22 -0500
  Re: C newb - Part III - find a .jhr file in a directory - seg fault BartC <bc@freeuk.com> - 2016-12-23 17:40 +0000
    Re: C newb - Part III - find a .jhr file in a directory - seg fault Keith Thompson <kst-u@mib.org> - 2016-12-23 14:13 -0800
      Re: C newb - Part III - find a .jhr file in a directory - seg fault Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-12-23 17:22 -0500
      Re: C newb - Part III - find a .jhr file in a directory - seg fault BartC <bc@freeuk.com> - 2016-12-23 22:35 +0000

csiph-web