/* 11.14.06, Kambhamettu: This program reads a file name, integer n,
and creates n files with .jpg extension to write.
*/
/* It shows this using sprintf, and also shows how to use string libraries
to do this */

#include <stdio.h>

main()
{

FILE *fw;
char name1[50],name2[50];
int i,n;

printf("Print the file to write:");
scanf("%s",name1);

printf("Print the number of files to write:");
scanf("%d",&n);

for (i=1;i<=n;i++)
{
sprintf(name2,"%s%d.jpg",name1,i);
fw=fopen(name2,"w");
fprintf(fw,"This is file %d\n",i);
fclose(fw);
}

strcpy(name2,".jpg");
strcat(name1,name2);
fw=fopen(name1,"w");
fprintf(fw,"Using string operations is fun!..\n");
fclose(fw);

}

