user-input

How can I escape forward slashes in a user input variable in bash?

谁说我不能喝 提交于 2019-12-10 13:47:01
问题 I'm working on a script to make setting up a Statamic site more efficient. The problem I'm running into is that the variable I'm using to replace a string in a file has unescaped forward slashes and is user input. How can I make sure that _site_url: http://statamic.com will become _site_url: http://example.com ? The code below will work as long as there are no forward slashes present. echo "What's your site URL? Don't forget the protocol (ex. http://)!" read -e SITE_URL echo "%s/_site_url:

trying to fill a 2D array by user-input how to do it?

▼魔方 西西 提交于 2019-12-10 11:58:38
问题 i am creating a code that allow user to enter his input to create a 2D array but it did not work as it should i do not know where is the problem if anyone can help me i will appreciate that. this my code : package test7; import java.util.Scanner; public class test7 { private int row = 4; private int col = 4; private int[][] matrix; public test7(int trow, int tcol) { this.row = trow; this.col = tcol; } public test7(int trow, int tcol, int[][] m) { this.row = trow; this.col = tcol; this.matrix

writing integer input to vector container in C++

蹲街弑〆低调 提交于 2019-12-10 10:27:19
问题 likewise we do in array for (.....) cin>>a[i]; how we can do this using vectors. i declared a vector of integers vector<int> v; now i need to take inputs from console and add append those in vector.i am using vector because i donot know the limit. 回答1: To insert integer to a vector from console and print everything out: int input; vector<int> v; while(cin >> input){ v.push_back(input); } for(int i = 0; i<v.size(); i++){ cout<< v[i] <<endl; } And vector also provides you to print out the max

Single character console input in java/clojure

独自空忆成欢 提交于 2019-12-10 04:06:56
问题 How can I read a single character/key from the console without having to hit Enter? There is an old entry in Sun's bug database claiming that it can't be done in pure java. I've found these approaches JNI JLine [http://jline.sourceforge.net/] Javacurses [http://sourceforge.net/projects/javacurses/] I'd expect to add a single magic-readkey.jar to my classpath, and to write a few lines of code, like (def just-hit (com.acme.MagicConsole/read-char)) . 回答1: Here's an "immediate echo" app using

Can keyboard of type UIKeyboardTypeNamePhonePad be made to start in phone mode?

拟墨画扇 提交于 2019-12-10 03:22:52
问题 Is there some way to have a keyboard of type UIKeyboardTypeNamePhonePad start in phone number pad mode rather than alphabetic? The keyboard works well for what I need but I'd like it to start in the "other" mode since that is more likely what the user will enter. 回答1: I believe that by setting the keyboardType property to UIKeyboardTypeNumbersAndPunctuation , you will default to the numbers and punctuation view, while still having the option of returning to the "ABC" view. Apple's

What percentage of my time will be spent in user input verfication during web development?

旧时模样 提交于 2019-12-09 16:47:02
问题 I'm new to developing things on the web. So far, I'm spending a lot of time (50% or so) to try and prevent bad people from putting things like sql injection into my input forms and validating it server side. Is this normal? 回答1: @Jeremy - some PHP specifics When it comes to database queries, always try and use prepared parameterised queries. The mysqli and PDO libraries support this. This is infinitely safer than using escaping functions such as mysql_real_escape_string. Yes, mysql_real

How to use InputConnectionWrapper?

荒凉一梦 提交于 2019-12-09 09:45:08
问题 I have an EditText . Now I want to get all changes made by the user to this EditText and work with them before manually inserting them into the EditText . I don't want the user to directly change the text in the EditText . This should only be done by my code (e.g. by using replace() or setText() ). I searched a bit and found an interesting class named InputConnectionWrapper . According to the javadoc it shall act as a proxy for a given InputConnection . So I subclassed it like this: private

Datetime conversion and parsing

六月ゝ 毕业季﹏ 提交于 2019-12-09 01:27:47
问题 My code gives the following error: Input string was not in a correct format. with this hint: When converting a string to DateTime, parse the string to take the date before putting each variable into the DateTime object Below is my code: (Edited to only show problematic code) string username ="aits"; string password = "12345"; Int32 intresortid=7; string strPartySurname = "Kumar"; ; string strPartyFirstName = "Test"; string strPartyPrefix = "Mr & Mrs"; Int16 intQtyAdults=1; Int16 intQtyTotal=1

How to get the last key pressed without stopping the C program?

点点圈 提交于 2019-12-08 14:37:41
Writing an application with command line interface and I would like to know at any time if F1 or ESC or an arrow key is pressed. What is the simplest way of doing this? I would like to avoid using a readline type library. This is a Linux specific question; the program is not multithreaded. An implementation of kbhit() for Linux is presented in Beginning Linux Programming page 167. You can read it on-line at the link provided. EDIT: I mention kbhit() because it was posted as a solution before it was made clear that the question related to Linux. Unfortunately the solution has been deleted,

Does the cin function add null terminated at the end of input? [closed]

喜夏-厌秋 提交于 2019-12-08 14:04:56
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . If I declare a character array: char arr[200] and then I subsequently use the function cin to read values into arr[200] and I type into the command window line: abcd Is there a null terminated: \0 automatically