Can I run other program in Ruby program and get result?

ts,thanks.
It works well under cygwin, but under Windows NT the result is “result : a.out”.
I think under Windows NT to do this must use WinAPI, so the result is different from
that under Linux.Is it right?

I write a hello world program using c++, which output “Hello world!”,
I compile it into hello.o. Now, I want to write a Ruby program, which can run
hello.o in it and catch the output “Hello world!”. What am I use in Ruby
to do this?

Well, if you want to call an external program you can use ``

igeon cat a.c
#include <stdio.h>
main()
{
printf(“Hello world !\n”);
}
pigeon

pigeon cc a.c
pigeon

pigeon cat b.rb
#!/usr/bin/ruby
res = a.out
puts “result : #{res}”

pigeon

pigeon b.rb
result : Hello world !
pigeon

Guy Decoux

    Sheen Zan
    zx@is.pku.edu.cn
      2002-11-09