Store the input in a char, then check whether it's a number. (using ASCII, http://www.ascii-code.com/ , so if the ASCII code of the input is between 48 and 57, it's a number).
also my project is a calculator,certain input need to be negative and possitive,i just want a way for the user to not be able to input a word o letter or for the program to send the user a warning that letters are not allowed and then loop back to insert the figure again.
It's impossible to enter a letter if you're reading an integer, your input fails, and you are probably not checking for that error, which is why an infinite loop happens.
Try something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <limits>
int main()
{
std::cout << "Enter a number\n";
int n;
while(! (std::cin >> n) )
{
std::cout << "That wasn't a number! Try again.\n";
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
std::cout << "Thank you for entering the number " << n << '\n';
}