I'm not really sure what this is asking me to do. Please help!
DUE at 9pm and I have no clue what to do.
I'll keep working on what I have though..
(see at end of post)


In this quiz you will write a program (quiz4.c) that sequentially
reads several files and writes their concatenated contents into
another file. The names of the files to be read and the file to
write to will be specified on the command line. For example, after
you compile your code and run:

iacs5.ucsd.edu% ./a.out quiz3.c quiz4.c output

the file output should contain the concatenated contents of both
quiz3.c and quiz4.c. The last parameter is always the name of the
file where you write to (destination file) whereas all other
parameters are the names of the files you read and concatenate in
the order they appear. Your program should perform the following
checks:

a) If less than two parameters are passed to the program, abort with
an error message (at a minimum there should be one file to read
and the destination file);

b) If a you cannot open the destination file for writing, abort with
an error message;

c) If you cannot open any of the files to be read issue a warning
message and continue to the next file. If this is the last file
then simply close the destination file and exit your program
without further messages.

You must use fgets in order to read files and fprintf to write to
the destination file. Take a look at program w6-5.c to see how fgets
works and program w5-8 to see how to retrieve command line
arguments.

HINT: You can use the unix commands cat and diff to check your
program. If you run

iacs5.ucsd.edu% ./a.out quiz3.c quiz4.c output.1
iacs5.ucsd.edu% cat quiz3.c quiz4.c > output.2

then the command

iacs5.ucsd.edu% diff output.1 output.2

should produce no output if you have done your job right. Otherwise
you will see a number of complaints about differences in the two
files.


quiz3.c & quiz4.c are just examples. In practice, any files you input should work (as long as the files exist).

Here's what I have so far:
I don't know if i'm anywhere close to the right answer..

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define FILEMAX 1000000

FILE *fp;

main ()
{
	
for(i=1; i<3; i++)
{
printf("Input filename:");
fscanf("%s",filename);
fp=fopen(filename, "a");
	if(fp==NULL)
	{
		printf("ERROR\n");
	}
		exit(1);
}

Thank you!!