Need is space to detect space from single input characters and print out the responses below.
seems (space) and (enter) are not working
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <ctype.h>
#include <stdio.h>
#include <cmath>
usingnamespace std;
int main()
{
// taking input
char letter;
cin >> letter;
// checking is it space
if (isspace(letter))
printf("\nThe character you entered is a whitespace character");
else
printf("\nThe character you entered is not a whitespace character");
return 0;
}
#include <iostream>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>
usingnamespace std;
int main()
{
// taking input
std::string input;
getline(cin, input);
if (input == " ")
printf("\nThe character you entered is a whitespace character");
else
printf("\nThe character you entered is not a whitespace character");
return 0;
}