Hello everyone, I wrote the following code and can´t exit the while(cin>>buf) loop through the command prompt,I tried pressing the enter button but didn´t work can you please help me:
#include <iostream>
using namespace std;
struct par{
char* name;
int val;
};
const int large=1024;
static par vec[large+1];
par* find(const char* p){
int i;
for(i=0;vec[i].name;i++)
if(strcmp(p,vec[i].name)==0) return &vec[i];
if (i==large) return &vec[large-1];
return &vec[i];
}
That operator>>() overload only returns false when the user's input cannot be converted to the type of the right hand operand. Since every user input can be converted to an array of characters, the overload will never return false.
I think sending EOF might work. Try hitting CTRL+Z or CTRL+D.