#include<stdio.h>
int main(int argc,char *argv[]) {
FILE *fp;
if (argc==3){
fp=fopen(argv[1],"w+");
fprintf(fp,"%s\n",argv[2]);
}
else {
printf("%s\n","This utility coded for UNIX/LINUX based systems can be used for setting small files with data in a hurry.The syntax is as fillowes.");
printf("%s\n","lw filename_to_open data_to_be written.");
printf("%s\n","The data to be written , i.e. the second argument must be quote delimited if the data contains spaces.");
printf("%s\n","Coded by Codezer0.Any bugs or further ideas please senf mail to:");
}
fclose(fp);
return 0;
}
In the above case when i give the 3 arguments required then the program is working fine. Anything other then the 3 args gives me the statement i enterd but with SEGMENTATION FAULT.can someone help me why am i getting this segmentation fault???