Im just creating my own library on file handling to make it more flexible,but I got stucked up at these point watch these below program
int filewrite(char *filename,unsigned char number)
{
FILE *dill;
if((dill=fopen(filename,"r"))==0)
return(0);// error no such file exists returns 0
else
{
if(number==0)
{
dill=fopen(filename,"w");
while(number!='x')
{
number=getche();
putc(number,dill);
}
}
else
{
dill=fopen(filename,"a+");
while(number!='x')
{
number=getche();
putc(number,dill);
}
}
}
}
for instance I made the condition not equal to x so if I enter x letter it gets terminated, but I want that to be used too.but what is the condition to be put to use all letters numbers and special symbols when we are writing into a file becuase If I hit enter then it goes to next line but its not terminating and I want to use enter too but how to say that this is the EOF using putc ? Help me guys