473,379 Members | 1,283 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Testing to see if user input is a number

Hi all,

I was wondering what function was the C++ equivalent for testing to see if a user input is numeric.

I have equivalents in Ruby, Java, Python, VB, VBA, php, but being a novice in C++, I have yet to find one - even with the help of Google.

And I know C++ is such a wonderful language, that its extensive library must have one somewhere - considering it's already 2013!

Thanks in advance!
Feb 10 '13 #1

✓ answered by weaknessforcats

Just do a cin >> an int variable.

Then call cin.fail(). I that's true you do not have a numeric value.

2 1383
weaknessforcats
9,208 Expert Mod 8TB
Just do a cin >> an int variable.

Then call cin.fail(). I that's true you do not have a numeric value.
Feb 10 '13 #2
Awesome. Thanks for the concise and accurate answer!

Also the kitten in the AV is probably one of the cutest ones I've ever seen.
Feb 10 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: hokiegal99 | last post by:
I don't understand how to use a loop to keep track of user input. Could someone show me how to do what the program below does with a loop? Thnaks! ---------------------------- #Write a...
12
by: agent349 | last post by:
Hi, I'm fairly new to c++. I need user input in the form of dollar amounts, ie: "$10.00". I'd like to remove the dollar sign "$" then store the rest in a variable. How do I go about removing the...
9
by: chuck | last post by:
I need some help with validating user input. I am writing a C computer program for an intro to C course. Here is the situation. I am creating an application that will do currency conversions. ...
1
by: yodadbl07 | last post by:
hey ive been messing around with this program to take a user inputed number, put it into an array and then reverse the number. I also want it to omit unecessary 0's at the begging. for example if...
3
by: td0g03 | last post by:
Like the titles says I'm suppose to generate a random number then divide that by a number inputed by a user. The random number can range from 2-8. I tried to do the code, but I get some weird result...
13
by: td0g03 | last post by:
Hello again guys. I have a question. I'm working on a program for my class and I'm stuck on how to find the lowest and highest number of a user input. We aren't at arrays yet so that's out of the...
14
by: n3o | last post by:
Hello Comp.Lang.C Members, I have an issue with user input that I have been trying to figure out for the longest. For instance, let's say you have something like this: void foo() { int num;...
4
by: myself2211 | last post by:
Hi, this is my first attempt at Python, what I am trying to achieve is a script that will ask the user for input, search a txt file and display the output or give not found message. Ideally I would...
3
by: rickytb | last post by:
Hey all, I've hit a snag on a beginner Java problem involving building occupancy. I'm supposed to get user input from a GUI. My main problem is that I'm totally lost on how to take the information...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.