Program to Find the words starting with a or A from the source code itself and then modify it by removing the words from the source code and put it in another file. The following code doesn't work. Pls Help!!!

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
void Write(fstream &a, char b[])
{ int i;
  for(i=0;b[i]!='\0';i++)
  {  a.put(b[i]);                     //Created a duplicate file of the source code
  }
}

void main()
{ clrscr();
  char *str,ch;
  fstream o,i;
  o.open("FILE.CPP",ios::in);        // adate sddf
  o.seekg(0);
  cout<<" Altavista App ";              //some words starting with A
  i.open("DUP.dat",ios::out);
  while(!o.eof())
  {  o.get(ch);
     i.put(ch);
  };                                // asprine ddjgdssd sdag sas aadfd
  i.seekg(0);
  o.close();
  fstream j("adate.dat",ios::out);
  o.open("TEMP.DAT",ios::out);
  while(!o.eof())
  { o.get(str,40,' ');
    if(str[0]=='a'||str[0]=='A')
    { Write(j,str);
    }
    else Write(o,str);
    strcpy(str, "\0");
  };
  cout<<"\n\n\t\t\tOperation Completed!";
  getch();
};

Reply fast pls.

No:

#include<iostream.h>

or

#include<conio.h>

or

#include<fstream.h>

or

#include<string.h>

One of the buggs resides on line 21. And also, don't read the file character by character, rather try to read the whole line, and than make moddifications on it. But I won't give any hops to this code, because it's... obsolete!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.