#include<iostream>
#include<string>
#include<cstdlib>
#include <windows.h>
#include <winuser.h>
using namespace std;
int main(){
string str;
getline(cin, str);
if(GetAsyncKeyState(8)) //checks to see if the input contained any backspaces
{
cout<<"Backspace was detected";
}
else{
cout<<"Backspace Not detected";
}
return 0;
}
or similarly using a character:
#include<iostream>
#include<string>
#include<cstdlib>
#include <windows.h>
#include <winuser.h>
using namespace std;
int main(){
char c;
cin.get(c);
if(GetAsyncKeyState(8)) //checks to see if the input contained any backspaces
{
cout<<"Backspace was detected";
}
else{
cout<<"Backspace Not detected";
}
return 0;
}
I now realised you are using C instead of C++ so all you do is change the libraries you are using.