I am trying a coding Q and am looking for a line of code that detects if there was no input given (user just presses enter). The concerned datatype is int.
I've read few other Qs about this very problem, but didn't fit in well with my needs. I have tried eof & other such suggestions to no avail...
Here's the code -
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main() {
int ogv,cgv=0,i,j=0,k;
int arr [3];
vector<int> ans;
while(true) {
cgv=0;
cin>>ogv;
//if("ogv is not a number, just an enter")
break;
arr[0]=floor(ogv/4);
arr[1]=floor(ogv/3);
arr[2]=floor(ogv/2);
for(i=0;i<=2;i++) {
if (arr[i]<0)
arr[i]=0;
cgv+=arr[i];
}
if(ogv>cgv) {
ans.push_back(ogv);
}
else {
ans.push_back(cgv);
}
j++;
}
for(k=0;k<j;k++) {
cout<<ans.at(k)<<endl;
}
}
Your help is greatly appreciated...! :D
Thanks