Change line 19 to:
prime.startnumb >> prime.number;
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
It's maybe better when you change line 11 to: ifstream startnumb;
You shouldn't forget to close the files when you don't need them anymore ...
BTW, on line 7 you're using #define to declare a constant, it's better to use const instead of #define ...
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Why ?
Consider the following program using #define :
#include <iostream>
using namespace std;
#define BEGIN 20
#define END 60
#define LENGTH END-BEGIN
int main()
{
cout << "LENGTH = " << LENGTH << endl;
cout << "2*LENGTH = " << 2*LENGTH << endl;
return 0;
}
Well, it doesn't return the result you expected ...
You probably expected it would return 80 ...
You don't have this problem using const :
#include <iostream>
using namespace std;
int main()
{
const int BEGIN = 20;
const int END = 60;
const int LENGTH = END-BEGIN;
cout << "LENGTH = " << LENGTH << endl;
cout << "2*LENGTH = " << 2*LENGTH << endl;
return 0;
}
Hope this helps !
BTW, const is invented to avoid the use of #define , so why would you continue using #define if you can use a better (and more C++ like instruction) ??
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243