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


Groups > comp.lang.c > #100097

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

From Lew Pitcher <lew.pitcher@digitalfreehold.ca>
Newsgroups comp.lang.c
Subject Re: C newb - Part III - find a .jhr file in a directory - seg fault
Date 2016-12-23 17:22 -0500
Organization The Pitcher Digital Freehold
Message-ID <o3k7vt$jnt$1@dont-email.me> (permalink)
References <azB3A.89805$dL2.72348@fx12.iad> <o3jnfl$n11$1@dont-email.me> <lnbmw2b8fu.fsf@kst-u.example.com>

Show all headers | View raw


On Friday December 23 2016 17:13, in comp.lang.c, "Keith Thompson"
<kst-u@mib.org> wrote:

> 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.

I believe that fnmatch() will be available on the system S390 uses; he's
already using the POSIX functions opendir(), readdir(), and closedir().

-- 
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request

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