From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Capturing output from C/C++ Date: Thu, 05 Mar 2015 13:00:36 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTa4l-0003Tk-Ew for emacs-orgmode@gnu.org; Thu, 05 Mar 2015 13:00:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTa4d-0007k2-BU for emacs-orgmode@gnu.org; Thu, 05 Mar 2015 13:00:47 -0500 Received: from smtp.andrew.cmu.edu ([128.2.105.202]:56773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTa4d-0007jJ-0z for emacs-orgmode@gnu.org; Thu, 05 Mar 2015 13:00:39 -0500 In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Roger Mason Cc: emacs-orgmode@gnu.org I think you need to tangle the file, compile it and run the executable in a shell block. Here is a Fortran example: http://kitchingroup.cheme.cmu.edu/blog/2014/02/04/Literate-programming-example-with-Fortran-and-org-mode/ I have done similar things with C, java, etc... before. I don't know of a built in way to type C-c C-c and have it do all those things for you. Roger Mason writes: > Hello, > > I have a short C++ program: > > #+BEGIN_SRC cpp :flags -lm :results output > #include > #include > #include // for ceil > #include // for atof > > double f (double fv, double o, int i) { > return fv / 2.0 + (1.0 - o) * fv * i; > } > > int num (double d, double fv, double o) { > return (int)ceil( d / ((1.0 - o) * fv )); > } > > int main (int argc, char* argv[]) { > if ( argc < 6 ) { > std::cout << "Usage:\n" << std::endl; > std::cout << "grid w fovx ox h fovy oy\n" << std::endl; > return 1; > } > ... > #+END_SRC > > that outputs some data to stdout. > > So far I have not been able to capture the output of the program back > into to my org buffer. > > Is that possible and, if so, how? > > Thanks, > Roger > Org-mode version 8.2.6 -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu