問題タブ [gets]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ruby - RubyFiddle の問題 - NameError: 未定義のローカル変数またはメソッド 'gets' #
私は単に「gets」を使用してユーザー入力を取得しようとしています。デフォルトでは、gets がファイルから情報を読み取ろうとするためである可能性があることを読んだことがあります。name = $stdin.gets および name = &stdin.gets.chomp などを試しましたが、同じエラーが発生します。
ruby - ruby (rubyinstaller) and cygwin odd behaviour with gets method inside a loop
I've been running quite a few ruby console scripts in cygwin terminal under windows xp with no problems so far using ruby 1.9.3-p28 from rubyinstaller.
All of a sudden now I'm noticing this odd behaviour. I have the following simple code:
which gives no output whatsoever in console. It seems the input = gets
part makes the while cycle hang for some reason. If I change the script this way
while cycle works as expected, but if I add the line input = gets
just below puts "ok"
it's hanging again, and strange thing is it doesn't even write "ok" to console just before hanging. It seems it's doing completely nothing and windows task manager shows ruby process has no activity at all.
I've also tried with loop do end
cycle, but behaviour is exactly the same.
Instead, things works ok if I use no cycle at all.
All I can understand is that it's related to stdin gets method inside a cycle.
I'd like if someone could help me debug what is exactly happening here.
UPDATE (more info): script correctly works in windows command shell.
javascript - コンソールで JavaScript を使用してユーザー入力を取得する
.js
次のように、spidermonkey を使用してコンソールで実行するときに、ユーザー入力を取得する必要があります。
$ js myprogram.js
Ruby に相当する JavaScript は何gets
ですか?
c++ - C++ での 2 つの gets() の使用
C++ のクラスについて学習しています。クラスの概念を使って簡単なプログラムを作りました。プログラムでは、本の詳細を入力する人が必要です。その関数は次のとおりです。
3 行目で、ユーザー入力を取得するために 2 つの get を使用する必要があることに注意してください。1つを使用する と、これが出力になります。gets ステートメントをスキップするだけです。同様に、他の場所でも 2 つの getchar ステートメントを使用する必要があります。SO自体でその答えを見つけることができました。Exなぜ私の教授。2 つの getchar を使用しています。ただし、2 つの get ステートメントの答えは見つかりませんでした。必要な場合の完全なコードを次に示します。
c++ - 前の入力の後に C++ で「gets」関数を使用する方法は?
関数でデータを入力しようとしましgets()
たが、プログラムの実行が でリーエンに到達するたびgets
に無視されます。
gets()
事前のデータ入力なしで使用すると、正常に動作します。しかし、データ入力後に使用すると問題が発生します。
前のデータ入力の後に使用されるコードは次のとおりです (実行中は文字列にデータを入力できません)。
どうすればこれを修正できますか?
注意: cin.getline でも同じことが起こります
ruby - Ruby の gets メソッドは入力を 256 文字で切り捨てます
Ruby で長い文字列 (> 256 文字、通常は < 512 文字) を入力しようとしています:
なんらかのばかげた理由で、常に入力を切り捨てて 256 文字 (chomp の前) のみを保持します。
Ruby がより長い文字列を受け入れ、Windows 7 コマンド ライン コンソールも 256 文字を超える文字列を受け入れることを確認しました。そのような制限がある gets メソッドについての言及は見つかりませんが、確かに何かが欠けています。私は無知です。それは単なる取得制限でしょうか?
編集:より具体的に言うと、私が使用しているテスト文字列の1つは次のとおりです。
6 は 256 番目の文字に対応します。示されているように、文字列は 256 番目を超えるすべての文字を切り捨てます。