473,473 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

inputs limiting and conversion in C Programming

1 New Member
how to limit inputs in c programming

for example limit number of inputs being taken from the user
May 27 '10 #1
2 1690
whodgson
542 Contributor
In the simplest sense you prompt a user with a cout<< or printf() statement and then provide the user with a scanf() or cin>> statement which will take her input.
You can use an if statement or try, throw and catch statements to control what will be accepted as input.e.g.:
Expand|Select|Wrap|Line Numbers
  1. cout<<"state your age";cin>>age;if(age<5||age >105)
  2. cout<<"are you sure";
May 27 '10 #2
Banfa
9,065 Recognized Expert Moderator Expert
You can't actually limit what the user types into stdin (the console) all you can do is read what is input and if it is not correct display and error and request the input again.
May 27 '10 #3

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

Similar topics

270
by: Jatinder | last post by:
I found these questions on a web site and wish to share with all of u out there,Can SomeOne Solve these Porgramming puzzles. Programming Puzzles Some companies certainly ask for these...
10
by: jeff regoord | last post by:
A user inputs a float value. The scanf() function gets the value. However, I need to create an error handler with an if else statement saying invalid input if the input is not a number. Does...
7
by: Connelly Barnes | last post by:
Hi Python folks, I created a summary PDF of two studies on programming language productivity: http://barnesc.blogspot.com/2006/05/programming-language-productivity.html One notes that Python...
21
by: gurdz | last post by:
Does anyone know how to perform data validation in C? I have searched google for every possible result, and I either end up with data validation for C++ or nothing at all. I have also searched...
1
by: enbulldog | last post by:
I am working on a program to "encrypt" a text file supplied by the user, and writing to another file also given by the user. I am very new to programming and am having trouble passing information...
7
by: newbiemom | last post by:
I am taking an online C++ Class and I am having trouble with the compiler . I typed in my source code and am trying to debug , But the problem is being that I am so new to this I don't understand...
2
by: algatt | last post by:
Hello, I am trying to compile the TPIE files but there is a file that's constantly giving errors about the templates. I am using gcc 3.4.5 on Eclipse using Windows XP. The following is the code of...
1
by: crazygrey | last post by:
I'm using VC++ 2005 Express on Windows XP. I'm reading and writing parallel ports' pins. I'm using 10 outputs (D0-D6, C0,C2,C3) - a combination of data pins and control pins , and 6 inputs (D7,...
2
by: Netwatcher | last post by:
Hello, i am new to c++ windows and DX programming, i encountered a code in the book stated in the title, which doesn't work for a reason, here is the code // Beginning Game Programming // Chapter...
7
by: rajesh6695 | last post by:
Which programming language will be suitable for GUI application development for Win CE 5.0 Device. Below are the some major features to be covered in GUI application 1. TCP/IP Communication (Hope...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.