Simple c++ help needed
I'm pretty sure there is a very simple way to do this but I haven't found a good explanation for how to do it. How would I go about getting an input from a user that I can verify is an integer?
One other question I have is related to code similar to this:
Now thats the code I have for finding factors of a number. I would want to add a percent type thing to it but I'm not sure how I would do that. I could divide 'loops' by 'innum' but how could I control how many decimal places are kept if i wanted to display something like xx.xx%
Thanks for any help in advance
One other question I have is related to code similar to this:
Code:
int factor(long innum)
{
int prev = 0;
ofstream factors;
factors.open("factors.txt");
if (factors.is_open())
{
factors << "Factors of " << innum << ":" << endl << endl;
for (long loops = 1; loops <= innum; loops++)
{
if (innum % loops == 0)
{
factors << loops << " ";
prev++;
}
if (prev == 7)
{
factors << endl;
prev = 0;
}
}
}
else
{
clearscreen
wait
cout << "Error opening file!!!" << endl << "Exiting...";
return(1);
}
factors.close();
return(0);
}
Thanks for any help in advance



