My program has no problems detecting space which i store in a character variable. The program returns zero but does not return one.
edit: changed '/n' to '\n' (typed wrong escape sequence for a new line) Also my question does not relate to the suggested question: std::cin:: and why a newline remains because that question is about a stray new line sequence in buffer as per my understanding while i simply demonstrated my failed attempt at trying to store an enter key in a char variable and using an if statement as a flag to detect an enter key.
This set up now works with the flag outputting one. However, I am still keen on learning new ways to store an enter key into a variable so that i can detect it via a flag or any other setup.
#include <iostream>
using namespace std;
int main()
{
char a;
cin.get(a);
if(a=='\n')
cout<<"one";
if(a==' ')
cout<<"zero";
return 0;
}