Code:

#include <stdio.h>
#include <stdlib.h>
#define MAXCHAR 256
void main( int argc, char *argv[])
{
int fibonacci(int n);
FILE *out=NULL;
int count;
char check[MAXCHAR];
char filename[MAXCHAR];
int number;
int fib[MAXCHAR];
int flag;
if(argv[1] == NULL){
printf("This program calculates a series of Fibonacci numbers\n");
}
if(argv[1] !=NULL){
strcpy(check,argv[1]);
}
if(argv[1] !=NULL){
if(strcmp(check, "/?") == 0 || argc < 3 || atoi(argv[2]) < 0){
printf("This program calculates a series of Fibonacci numbers\n");
flag = 1;
}
strcpy(filename, argv[1]);
}
if(argc >= 3 && flag != 1) {
out = fopen(filename, "w");
}
printf("Test 1\n");
if(argc >= 3 && flag != 1){
if(isdigit(argv[2]) !=0){
number = atoi(argv[2]);
printf("The first %d Fibonacci numbers\n",number);
}
else{
printf("This program calculates a series of Fibonacci numbers\n");
flag=1;
}
}
if(argc >=3 && flag != 1){
for(count = 0; count < number; count++){
printf("%d ",fibonacci(count));
}
}
if(argc >=3 && flag != 1){
fprintf(out,"The first %d Fibonacci numbers\n",number);
for(count = 0; count < number; count++){
fprintf(out,"%d ",fibonacci(count));
}
}
printf("\nTest 2\n");
if(out !=NULL){
fclose(out);
}
}