Xref: utzoo comp.sys.atari.st:17744 comp.lang.c:19899 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!ncar!asuvax!hrc!gtephx!covertr From: covertr@gtephx.UUCP (Richard E. Covert) Newsgroups: comp.sys.atari.st,comp.lang.c Subject: string comparisons in C Keywords: C, atari st, mark williams Message-ID: <44672745.14a1f@gtephx.UUCP> Date: 13 Jul 89 22:30:56 GMT Organization: AG Communication Systems, Phoenix, Arizona Lines: 22 This is not a flame. Mark Williams C is a wonder. The manual is so full of GEM/AES/VDI hints that it still amazes me after two years! Anyway, C has a lack of good string handling operations, so you need to use library functions. I was writing a program in which I needed to determine whether a certain file type was a member of a desired set. So, how do you do string comparisons in C?? The normal, portable, way is to do a char search and match. Slow and ugly. But, I was browsing thru the MWC manual, and lo and behold I see pnmatch(). Now pnmatch is a wonderful little function which does string comparisons. And it even accepts wildcards, so I was in business. I just build an array of strings such as "*.PI1", and then by looping thru the array I can string compare a user inputted filename against the list of legal filetypes. Pretty neat solution. So, the moral of this little ditty, is READ YOUR MANUAL!! P.S. Does anyone know if pnmatch() is implemented on other C compilers?? Richard (gtephx!covertr) Covert