help broke prog up into functions now not working

From: David. E. Goble (degoble_at_gtech.computing)
Date: 01/30/05


Date: Mon, 31 Jan 2005 08:20:23 +1030


#include <stdio.h>
#include <string.h>

#define FALSE 0
#define TRUE 1
#define LINESIZE 255

int setupoutfile(char filename[], FILE *outfile)
{
    strcat(filename, ".js");
    outfile=fopen(filename, "w+");
    if(!outfile)
    {
    sleep(TRUE);
    outfile=fopen(filename, "w+");
    if(!outfile) return -1;
    }
return 0;
}

int setupinfile(char filename[], FILE *infile)
{
    infile=fopen(filename, "r+");
    if(!infile)
      {
      sleep(TRUE);
      infile=fopen(filename, "r+");
      if(!infile) return -1;
      }
return 0;
}

int mymenu(FILE *infile, FILE *outfile)
{
char line[LINESIZE]="\0";
int i=0;

    while(fgets(line, LINESIZE, infile)!=NULL)
         if(strstr(line, ".gif")!=NULL || strstr(line, ".jpg")!=NULL)
         {
         line[strlen(line)-1] = '\0';
         fprintf(outfile, "myImages[%d]=\"%s\"\n", i++, line);
         }
return 0;
}

int main(int argc, char *argv[])
{
FILE *infile, *outfile;

     if(argc>2) setupoutfile(argv[2], outfile);
     if(argc>1) setupinfile(argv[1], infile);
     else
       {
       printf("mymenu infname basefolder -> basefolder.js\n");
       return -1;
       }
     mymenu(infile, outfile);
return 0;
}

Regards David. E. Goble
                           http://www.pnc.com.au/~degoble
             degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
 Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223



Relevant Pages

  • Re: Strange pager (less, more) behavior
    ... static FILE *openfile (const char *filename, ... static int closefile (FILE *f, ... FILE *outfile, ... while, infile)) ...
    (comp.os.linux.development.apps)
  • Re: How to insert data after 10 line
    ... > echo 1> filename ... sed '11i1' infile> outfile ...
    (comp.unix.shell)
  • Re: file class
    ... private String _FileName; ... /// filename and all reqired parameters must be set up by user ... public TextFileServer(string FileName, int FixedRecordLen) ... //End of line built from constructor or user manual ...
    (microsoft.public.dotnet.languages.csharp)
  • file class
    ... private String _FileName; ... /// filename and all reqired parameters must be set up by user ... public TextFileServer(string FileName, int FixedRecordLen) ... //End of line built from constructor or user manual ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: file class
    ... private String _FileName; ... /// filename and all reqired parameters must be set up by user ... public TextFileServer(string FileName, int FixedRecordLen) ... //End of line built from constructor or user manual ...
    (microsoft.public.dotnet.languages.csharp)