I am having some issue with clearing cin buffer. The following code does not wait for me to see the output window and till I hit return character.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include "iostream"
#include "stdio.h"
#include "math.h"
#include "string"
#include "sstream"
usingnamespace std;
int main(){
int num;
cout << "Enter the number to print factors: ";
cin>>num;
cin.clear();
std::cin.ignore(INT_MAX, '\n');
cout << "1*" << num << endl; //printing the first factor of number * 1
printFactors("", 1,num);
getchar();
return 0;
}
> The following code does not wait for me to see the output window
If you mean that it doesn't stop at line 14, that's because you've pressed <Return> after inputting the number
If you mean at line 16, then we'll need to see `printFactors()' definition