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;