hi avery one i need this help ?

i want to do
a program to read ome nubers from the file and print only the negative odd nubers in another file ???

Member Avatar
#include <fstream>
using namespace std;

int main()
{
   ifstream fin;
   fin.open("sourceFile.txt");
   if (fin.fail())
      return 1;

   ofstream fout;
   fout.open("destFile.txt");
   if (fout.fail())
      return 1;

   int currentNumber;
   while (!fin.eof())
   {
      fin >> currentNumber;
      if (currentNumber % 2 != 0 && currentNumber < 0)
         fout << currentNumber;
   }

   fout.close();
   fin.close();

   return 0;
}

There's kind of what you want. I just wrote it without testing, so apologies in advance if there are errors.

commented: We don NOT do homework for people. We are an anti-cheating board. We do, however, GUIDE people to finding their own answers. -3
commented: would you mind me sending you my homework? +0