Automatic Filename Extensions

Craig Schmackpfeffer craig at srs.UUCP
Mon Apr 11 22:27:22 AEST 1988


In article <12901 at brl-adm.ARPA> C04661DC%WUVMD.BITNET at CUNYVM.CUNY.EDU (David Camp) writes:
>
>     A programming technique I have frequently used is:
>
>if (strchr (filename, '.') == NULL)
>    strcat (filename, ".EXT");
>-David-

Here at SR, we have many signal processing programs which are able to
contort signals into just about any new format.  We have adopted "."
suffixes (which can be supplied on the command line) to help organize 
this mess.

The big problem occurs when you try to do > 1 extension.  Our solution
was to write an add_extension(fname, extension) function.  If extension is
not empty (or not NULL), fname is truncated after the last '.' and extension
is appended.  It works very nicely.

Craig
-- 
Craig Schmackpfeffer  @ S.R. Systems
{allegra,rutgers,ames}!rochester!srs!craig



More information about the Comp.lang.c mailing list