Questions tagged [user-input]

User Input is data that the user inputs into the program. It generally takes the form of a String, but may also be an integer, floating-point number, etc.

5580 questions
13
votes
8 answers

How do you write a C program to increment a number by keypress and auto-decrement it per second?

I'm trying to write a program in which a number starts from 0, but when you press any key, it gets incremented by 1. If nothing is pressed, it keeps on decreasing by 1 per second until it reaches 0. Every increment or decrement is displayed on the…
Ritika
  • 149
  • 1
  • 5
13
votes
7 answers

HTML Input field force numbers

Is it possible to create an input field that sets the default input character set to numbers on a mobile phone (so the NUMERICAL KEYBOARD POPS UP)? For example to make it easier type in a telephone number into a HTML form.
user
  • 6,567
  • 18
  • 58
  • 85
13
votes
15 answers

Safely prompt for yes/no with cin

I'm in an intro to C++ class and I was wondering of a better method of checking if input was the desired type. Is this a good way of doing this? I come from a PHP/PERL background which makes me rather apprehensive of using while loops. char…
Levi
  • 12,214
  • 14
  • 43
  • 47
13
votes
7 answers

detecting end of input with cin

I want to read a line of integers from the user. I'm not sure how to check to see if the input has ended. For example I want to be able to do something like int x[MAX_SIZE]; int i = 0; while(cin.hasNext()) { cin >> x[++i]; } Example input: 2 1 4…
Celeritas
  • 14,489
  • 36
  • 113
  • 194
12
votes
6 answers

How to Test Character Input to UITextField as the User Enters Characters and Prevent Invalid Characters

First, I setup up the keyboard for the UITextField to use the number with decimal style. So the user can only enter numbers and a single decimal. What I want to do is test the input as the user enters it and prevent multiple decimals from being…
Seamus
  • 3,191
  • 3
  • 22
  • 20
12
votes
4 answers

What is the fastest way to determine a key press and key holding in Win32?

What is the fastest way to determine a key press and also how to determine if a key is being held? It appears that window messaging is slow. Please provide an example of how to do so, and why it is faster than an alternative. To be clear, this for a…
judeclarke
  • 1,106
  • 5
  • 16
  • 31
12
votes
3 answers

How do I sanitize user input for proper content-encoding before I save it?

I've got an application where users input text into forms. The data is saved into a MySQL database (collation: utf8_general_ci) and then output as XML (encoding: UTF-8). The problem is that people tend to cut and paste their information from other…
AmbroseChapel
  • 11,957
  • 7
  • 46
  • 68
12
votes
4 answers

How to read a binary number as input?

Is there a way for the user to input a binary number in C or C++? If we write something like int a = 0b1010; std::cout << a << std::endl Then the output comes out to be 10 (when using the appropriate compiler extensions). but when we try to…
iec2011007
  • 1,828
  • 3
  • 24
  • 38
12
votes
12 answers

Strategy for tracking user recent activity

Our customer would like to know who is online and currently using the custom application we wrote for them. I discussed it with them and this does not need to be exact, more of a guestimate will work. So my thought is a 15 minute time interval to…
mattruma
  • 16,589
  • 32
  • 107
  • 171
12
votes
1 answer

Make a line break when requesting user input (/P) in batch?

Is it possible to create a line break after a set /P command? I would like the user to be able to type on a new (blank) line instead of next to the existing prompt. For example: set /P test=type now echo %test% This code simply lets the user type…
EpicCyndaquil
  • 263
  • 2
  • 3
  • 17
11
votes
2 answers

readLines function with new version of R

My function is: create_matrix <- function() { cat("Write the numbers of vertices: ") user_input <- readLines("stdin", n=1) user_input <- as.numeric(user_input) print(user_input) } With the version 3.5.0, after i entered the data the…
Dr.mincode
  • 121
  • 5
11
votes
2 answers

Angular 2 Custom Validator: check if the input value is an integer?

In an Angular2 project I need to validate some inputs. How to easily check if an input value is an integer? I tried using Number(control.value) which returns 0 for an empty field - not good. or parseInt(control.value,10) which dis-considers…
AIon
  • 12,521
  • 10
  • 47
  • 73
11
votes
1 answer

Compile sass file inside browser

I am trying to go about creating a system for my users where they can select particular SCSS files they would like to be included in the project. They do this through a browser. Once they check off all the related SCSS files, they want to hit a…
webkitfanz
  • 1,305
  • 1
  • 16
  • 29
11
votes
4 answers

Formatting secure text entry by inserting visible spaces

I want the user to enter a Social Security Number in the format ••• •• ••••. The user types the first 3 numbers, then I append a space manually. Then they enter 2 more numbers and I manually append a space. Of course, even the spaces are being…
Zia
  • 14,622
  • 7
  • 40
  • 59
11
votes
1 answer

prompt for user input when running scala program with sbt

I have a very simple scala program: object TakeInputs { def main(args: Array[String]) { val name = readLine("What is your name?") println(name) } } When I try to run this with sbt "project myproject" "run-main TakeInput" it doesn't…
Xiang
  • 115
  • 1
  • 5