/************************************************************/
/*                                                          */
/*  The cpp file of test file generator program             */
/*  For CS 145 (Fall 2003) Lab 3                            */
/*  Author: Xiaoliang (David) Wei                           */
/*  Date:   Dec 05, 2002                                    */
/*                                                          */
/************************************************************/


/*
Command Line format:
generate <size> <Filename>
*/


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


FILE *outfile; //Input file. 

int size;

int main (int argc,char *argv[])
{

	size=atoi(argv[1]);

	outfile=fopen(argv[2],"w");
	if (outfile==NULL)
	{
		printf("Erorr when reading file!");
		return 1;
	}
	
	for (int i=0;i<size;i++)
	{
		long int x=random();
		char a=(x%52);
		if (a>=26)
		{
			//lower case
			a=a-26+'a';
		}
		else
		{
			//upper case;
			a=a+'A';
		}
		
		int rval=fwrite(&a,1,1,outfile);
		if (rval!=1)
		{
			printf("Incomplete writing to the file %d vs %d\n", rval, 1);
		}
	}
	fclose(outfile);
};


