标签: input

在Java中将用户输入解释为变量名?

所以,我正在尝试继续我的长颈鹿计划(不要问).我希望用户为他们的长颈鹿命名,这应该是长颈鹿的名字.例如:

System.out.println("Name your giraffe.");

就像是:

Giraffes.somenewvariabletype scannerexample.nextLine() = Giraffes.Giraffe(parameter, parameter)

java variables input java.util.scanner

-1
推荐指数
1
解决办法
2192
查看次数

如何检查输入多于占位符

我有这样的输入字段

<input type="number" id="return_pro" name="available" placeholder="10 Available">
Run Code Online (Sandbox Code Playgroud)

如果用户输入的值大于10(可用),则不应接受并应显示错误.我怎样才能做到这一点?我需要在输入标签本身使用它.因为文本字段位于foreach循环中.因此,文本字段的数量可能会增加.

html javascript validation input

-1
推荐指数
1
解决办法
94
查看次数

文本游戏 - 将输入文本转换为小写 - Python 3.0

((针对上述编辑,上述链接未对此进行回答.上述问题与我的预期用途无关.))

我读过一个关于将字符串变成小写的类似问题;

如何在Python中将字符串转换为小写

我理解这是如何完美的,但是我自己的尝试失败了.

这是我当前调试块的设置示例;

#Debug block - Used to toggle the display of variable data throughout the game for debug purposes.
def debug():
    print("Would you like to play in Debug/Developer Mode?")
    while True:
        global egg
        choice = input()
        if choice == "yes":
            devdebug = 1
            break
        elif choice == "Yes":
            devdebug = 1
            break
        elif choice == "no":
            devdebug = 0
            break
        elif choice == "No":
            devdebug = 0
            break
        elif choice == "bunny":
            print("Easter is Here!")
            egg = …
Run Code Online (Sandbox Code Playgroud)

python text input lowercase

-1
推荐指数
1
解决办法
2万
查看次数

打印char数组后为什么会有10?

我想知道,为什么我的打印结尾总会有10个.

我正在尝试输入带空格的字符串,然后打印出所有字符.

输入: hello

输出: 104 101 108 108 111 10

应该输出: 104 101 108 108 111

  unsigned char input[256];
  fgets(input,sizeof(input),stdin);

  for(int i = 0; input[i] != '\0'; i++) {
    printf("%u ",input[i]);
  }
Run Code Online (Sandbox Code Playgroud)

c input

-1
推荐指数
1
解决办法
58
查看次数

如何从java中的标准输入读取长值?

util.Scanner用来读取用户的输入.我不明白如何读取长数据类型值.

Scanner scr=new Scanner(System.in);
long l=scr.nextInt();
Run Code Online (Sandbox Code Playgroud)

我无法使用上面的代码读取64位数据 - 它只是给我一个输入不匹配异常.

java input long-integer

-1
推荐指数
1
解决办法
2万
查看次数

C中的字符数组

我正在尝试创建一个获取字符串的函数,通过char获取char:

char * GetString (int dim) // dim is the size of the string
{
    char c, *S;
    int i = 0;

    S = (char*)malloc(dim*(sizeof(char));

    while ((c=getchar() != '\n') && (i < dim) && (c != EOF))
    {
        S[i] = c;
        i++;
    }

    S[i] = '/0';

    return S;
}
Run Code Online (Sandbox Code Playgroud)

问题是当我尝试在此函数中使用"printf"时,试图查看输入是否正确,它显示奇怪的字符,而不是我插入的字符.我不知道我错过了什么.

非常感谢.

c arrays string input char

-1
推荐指数
1
解决办法
82
查看次数

检查数字或文本字符串的输入框

我正在实现逻辑以使用url作为查询参数,具体取决于用户是否输入一系列数字或字母.如果用户输入数字,urlLocation则应使用第一个,否则应使用第二个.试图为第一个使用正则表达式,但我不确定如何正确实现该正则表达式.

<input id="imageid" type="text" />

if ($("#imageid").val() == '/[^0-9\.]/') {
    var urlLocation = "http://www.url.com/rest/v1/cms/story/id/" + imageid.value + "/orientation/" + orientation;
} else {
    var urlLocation = "http://www.url.com/rest/v1/cms/story/guid/" + imageid.value + "/orientation/" + orientation;
}
Run Code Online (Sandbox Code Playgroud)

JSFIDDLE示例:链接

javascript regex jquery input

-1
推荐指数
1
解决办法
163
查看次数

从c中的文本文件中读取整数

我想读取一个文本文件,其中图像像素值以这种方式存储

234
23
176
235
107
187
201
128
147
...
....
..
Run Code Online (Sandbox Code Playgroud)

我试图以这种方式阅读这个文本文件

#include<stdio.h>
#define M 2500
int main()
{

unsigned  new_img[M];
unsigned char a;
FILE *input;
input=fopen("D:/trail.txt","r");
for(i=0;i<M;i++)
{
    a=fgetc(input);
    new_img[i]=(int)a; 
    input++;
}
....

....

...
return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我尝试打印它时显示一些随机值.此外,我所有的像素值都在0到255的范围内.但在输出屏幕上我得到的值大到1到100万

c file-io input fgets

-1
推荐指数
1
解决办法
2153
查看次数

检查输入字段是否包含@字符?

我试图检查我的输入字段是否包含@符号

所以这就是我所拥有的并且它不起作用:

$( "#Button" ).click(function() {
    if ($('#email:contains("@")')) {

    } else { 
        $('#email').text('Wrong');
    }
});
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/xJtAV/70/

有任何想法吗?

javascript validation jquery input

-1
推荐指数
1
解决办法
6343
查看次数

如何使用文件结构?

我有一个小问题,我有当前的文件结构: 在此输入图像描述

这是我的代码:

#include <stdio.h>
#include <stdlib.h>

const char FILE_NAME[] = "inputfile.txt";

int main()
{
    FILE *in_file;    /* input file */

    in_file = fopen(FILE_NAME, "r");
    if (in_file == NULL) {
        printf("Cannot open %s\n", FILE_NAME);
        exit(8);
    }else{
        printf("File opened %s\n", FILE_NAME);
    } 
    fclose(in_file);
    return (0);
}
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

无法打开inputfile.txt

但文件就在那里.有人能帮我吗?

(如果我将"r"更改为"w",我可以写入文件,但我在SSD上找不到该文件)

c file-io file input

-1
推荐指数
1
解决办法
64
查看次数