All pastes #839064 Raw Edit

Something

public text v1 · immutable
#839064 ·published 2007-12-30 20:47 UTC
rendered paste body
  ifstream in("primtal.txt",ios::in |ios::binary);
  if (!in) {
          cout << "Could not open file" << endl;
          system("pause");
          exit (1);
          }
  print_d("Indlæser primtal.txt\n");
  do {
      count++;
      array = (int*) realloc(array, count * sizeof(int));
      if (array==NULL) {
           puts ("Error (re)allocating memory"); 
           exit (1);
      }
      in >> array[count-1];
  } while (!in.eof());
  in.close( );
  print_d("Der er indlæst: ");
  cout << count << " primtal.\n";
  print_d("Tallene går fra: ");
  cout << array[0] << " til " << array[count-1] << endl;