我正在编写一个程序来执行另一个用 c 编写的程序,这是我的第一次尝试
require 'Open3'
system 'tcc temp.c'
Open3.popen3('temp.exe') do |stdin, stdout, stderr|
stdin.puts '21\n'
STDOUT.puts stdout.gets
end
实际输出:
Enter the temperature in degrees fahrenheit: The converted temperature is -6.11
所需的输出:
Enter the temperature in degrees fahrenheit: 21
The converted temperature is -6.11
如果您知道更好的方法,请告诉我,我是 ruby 新手。