Thread: Compiling Problem

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    241

    Compiling Problem

    My program is this. It will not compile because it says that there is an error with clrscr(). Can anyone help?

    Code:
    #include <iostream>
    #include <fstream>
    #include <conio.h>
    #include "primes.h"
    
    using namespace std;
    
    long primes[1000000L];
    
    int main(int argc, char* argv[])
    {
    	number prime;
       char pf[40];
       long a,counter=0;
       long aaaa=2000000000L;
       cout << "Enter the name of the file to put primes into: ";
       cin.get(pf, 400);
       cin.ignore(80,'\n');
       ofstream outfile;
       outfile.open(pf,ios::out);
       if(outfile)
       {
       	for(a=2;a<=aaaa;a++)
       	{
       		prime.SetValue(a);
          	if (prime.isPrime())
          	{
                clrscr();
          		outfile << a << endl;
             	counter++;
                cout << counter;
          	}
       		if (counter==10000000L)
          		a=aaaa;
       	}
          cout << "\nNumbers found";
          cout << "\nDone";
          outfile.close();
       }
       else
       {
       	cout << "An error occured while opening the file.\n";
       }
    	return 0;
    }

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    241
    That doens't really help, and it did work fine with vc++6, but isn't working with vc++ 7

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    99

    hmm

    Try using system("PAUSE");

  5. #5
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    do
    #include <stdlib.h>

    int main()
    {
    system("CLS"); //clears the screen
    return 0;
    }

    system("PAUSE") just write 'Press any key to continue...' on the screen, it doesn't clear it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Running Program After Compiling
    By kristentx in forum C++ Programming
    Replies: 13
    Last Post: 09-12-2007, 10:46 AM
  2. Problem compiling simple code examples
    By Wintersun in forum Windows Programming
    Replies: 8
    Last Post: 08-14-2007, 10:30 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. compiling problem
    By tinkerbell20 in forum C++ Programming
    Replies: 6
    Last Post: 06-21-2005, 12:12 PM
  5. simple compiling problem
    By waxydock in forum C++ Programming
    Replies: 2
    Last Post: 03-26-2005, 10:33 AM