Originally Posted by
Salem
So what's your question?
A random bit of code with no context and a "it doesn't work" topic doesn't help much.
char *fn;
char fn[5];
for example could be the simple mistake.
Code:
void main()
{
int i,c;
char fn[40],ch;
char filename2[200];
FILE *fptr1,*fptr2;
clrscr();
printf("Enter name of the destination file:");
scanf("%30s",filename2);
for(i=0;i<30;i++)
{
sprintf(fn,"C:\\USERS\\LXL[%d].pdb",i);
printf("%s",fn);
if((fptr1=fopen(fn, "r"))==NULL)
{
printf("Problem, cannot open the file for reading.\n");
}
else
if((fptr2=fopen(filename2, "a"))==NULL)
{
printf("Problem, cannot open %s for writing.\n", filename2);
}
else
{
LineReadWrite(fptr1, fptr2);
if(fclose(fptr1)==0)
printf("The file is successfully closed.\n");
if(fclose(fptr2)==0)
printf("%s successfully closed.\n", filename2);
}
I have 30 files, which i need to read and extract info and write the data in a single file. I hope its clear now.