user-input

How to read a string from user input in C, put in array and print

帅比萌擦擦* 提交于 2019-12-11 20:09:27
问题 I'm fairly new to C and I've read a few chapters of a C book I have and now I have to make an assignment but I am all confused hope someone can help me out. I have to read 2 strings from user (char arrays) input with a max length of 100 characters and convert them to capital letters and print them out with a newline \n after each word. Until now I have this: int main() { char chars[100]; int i = 0; char str1; char str2; int j = 0; scanf("\n %c", str1); scanf("\n %c", str2); while (str1[i] !=

My simple key listener isn't working. It doesn't seem to toggle the pressed boolean. (Java)

风格不统一 提交于 2019-12-11 16:49:06
问题 I'm using this for a simple 2.5D game but my keys don't seem to toggle. It isn't a problem while calling it in the main class as placing println statements in the if statements didn't run. Thanks ahead of time. import java.awt.event.KeyEvent; import java.awt.event.KeyListener; public class InputHandler implements KeyListener { public InputHandler(Game game) { game.addKeyListener(this); } public class Key { private boolean pressed = false; private int numTimesPressed = 0; public boolean

proper way to read user input from command line in java

蓝咒 提交于 2019-12-11 16:47:49
问题 I was hoping to get some opinions regarding best practices and comments on the way I read user input from the command line. Is there a recommended way to do this, am I using the try/catch blocks properly? My example here works fine, but would still like to hear if there is a 'cleaner' way to do this. Many thanks. For example are he return statements in each catch block necessary? Or, should I put my logic (the conditionals) within the try block? public class Client { public static void main

C# - Find/Edit/Replace String

喜欢而已 提交于 2019-12-11 14:42:25
问题 I am trying to retrieve data from a file to change it and replace the old data. I have a file that looks something like this: TEXT NEXT_TEXT 10.505 -174.994 0 TEXT NEXT_TEXT 100.005 174.994 90 TEXT NEXT_TEXT -10.000 -5.555 180 TEXT NEXT_TEXT -500.987 5.123 270 TEXT NEXT_TEXT 987.123 1.000 180 TEXT NEXT_TEXT 234.567 200.999 90 I am trying to grab the 3rd and 4th columns to change the data based on what a user inputs into two TextBoxes . Let's label the 3rd column "X" and the 4th column "Y" .

redirect any user input to a separate underlying program

微笑、不失礼 提交于 2019-12-11 13:11:16
问题 This is my virgin post so please go easy on me ! I am writing a program in C# which I want to run maximized and always-on-top. The app will be translucent so that a user can still see everything that's going on behind my maximized application. I am aiming to achieve a scenario where a user can (despite my app having focus) still interact as normal with all other running programs - as if it was a piece of coloured glass which merely redirects all user input to another intended application, eg

process.diagnostic waiting for user input

筅森魡賤 提交于 2019-12-11 12:43:30
问题 I have a simple WPF application that communicates with another console program. I use Process.Diagnostic to launch the console app. That console app has a prompt so I can send the input through StandardInput and read the outcome through StandardOutput . I want to launch the console application only once (keep it alive whole time) when the WPF apps loads and keep sending input and reads the output. I have some piece of code but I don’t how to put it all together. The problem is that after

C - scan user inputs into an array to be sorted

本秂侑毒 提交于 2019-12-11 09:31:26
问题 Forgive me, I'm a C programming rookie. What I need to do is take values from standard input and store them in an array which is to be sorted later on down the line. The method of entry for the user is one number on one line at a time (i.e. enter a number, press enter, enter number, press enter, etc..). When the user is done entering numbers, they press ENTER without providing a number. My code for accepting the values and storing them is as follows. You'll probably see the issue immediately,

VBA Select Random Row In Range of Select

自作多情 提交于 2019-12-11 09:07:59
问题 I am simply trying to select a random row within a user selected range. However, at times the program will select a random row outside of the specific range. See code excerpt below: Dim PopulationSelect As Range Set PopulationSelect = Application.InputBox("Select range of cells in the population", Type:=8) RandSample = Int(PopulationSelect.Rows.Count * Rnd +1) Rows.(RandSample).EntireRow.Select Does anyone know why this is, and how to fix it? Thank you in advance. 回答1: It's because your

saving user input from uitable matlab GUI?

我们两清 提交于 2019-12-11 08:32:04
问题 I'm creating a GUI (not using GUIDE) I'm looking for a convenient way for a user to enter some data. I figured uitable would be ideal except i can't seem to figure out how to store the user input from the table. I'd rather not use the celleditcallback function - ideally i'd like to save out the data all at once at the end using a save button or similar, any ideas? code for the table (this is within it's own function): dat = {0, 0, 0, true;... 0, 0, 0, true;... 0, 0, 0, true;}; columnname = {

Trying to loop just some parts of a math quiz program

北战南征 提交于 2019-12-11 07:40:02
问题 I'm trying to figure out the best way to loop this simple math quiz program (best here meaning the neatest and simplest method). I get two random numbers and their sum, prompt the user to enter, and evaluate that input. Ideally, it should get new numbers when they want to play again and ask the same question when the prompt is not a valid answer...but I just can't seem to wrap my head around how to go about it. import random from sys import exit add1 = random.randint(1, 10) add2 = random