You can use std::noskipws to disable the whitespace skipping that std::cin does by default:
#include
#include
int main() {
char c;
std::cin >> std::noskipws;
while (std::cin >> c) {
if (c == ' ')
std::cout << "A space!" << std::endl;
}
return 0;
}