Jump to content

help copy file?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
softvnn

softvnn

    Newbie

  • Members
  • Pip
  • 1 posts
Write a C program to copy the contents of one file onto another excluding the words a,an,the
code:
#include<stdio.h>
#include<conio.h>
void main()
{ FILE *fp1,*fp2;
  char ch1,ch2,ch3;
  fp1=fopen("file1","w+");
  fp2=fopen("file2","w+");
  printf("\n Enter file 1\nEnter string:");
  do { ch1=getchar();
	 if(ch1!='@') fputc(ch1,fp1);
	 else break;
	}while(ch1!='@');
	rewind(fp1);
  [COLOR="Red"] while(!feof(fp1))
  { ch1=fgetc(fp1);ch2=fgetc(fp1);ch3=fgetc(fp1);
	 if(ch1=='a'&&ch2!='n')  { fseek(fp1,-2*sizeof(char),1);continue; }
    if (ch1=='a'&&ch2=='n')  {fseek(fp1,-sizeof(char),1);continue;}
    if (ch1=='t'&&ch2=='h'&&ch3=='e') continue;
		fputc(ch1,fp2);  fseek(fp1,-2*sizeof(char),1);
  }[/COLOR]
	rewind(fp2);
	while(!feof(fp2)) putchar(fgetc(fp2));
	fcloseall();
	getch();
 }
help me? code mistake ??

Edited by WingedPanther, 02 September 2008 - 07:18 AM.
add code tags


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What are you entering?
What is it producing?
Are you getting an error message?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog