Create a file and add text at load time

Write a program to create a file and add some text to it at load time.

#include<stdio.h>
int main(int argc,char**argv)
{
	char cp[100];
	int i;
	FILE *fp;
	if(argc < 3)
	{
		printf("Usage:./a.out filename string(s) !\n");
		return 0;
	}
	fp = fopen(argv[1],"w");
	for(i = 2;i < argc;i++)
	{
		fprintf(fp,"%s\n",argv[i]);
	}
	fclose(fp);
	return 0;
}

Output

./a.out data LotToLearn

Checking the content of the file using cat command.

cat data
LotToLearn