emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Capturing output from C/C++
Date: Thu, 05 Mar 2015 13:32:38 -0500	[thread overview]
Message-ID: <87ioefb8hl.fsf@alphaville.usersys.redhat.com> (raw)
In-Reply-To: y657fuvflzr.fsf@cryptoperthite.esd.mun.ca

Roger Mason <rmason@mun.ca> writes:

> Hello,
>
> I have a short C++ program:
>
> #+BEGIN_SRC cpp :flags -lm :results output
> #include <iostream>
> #include <fstream>
> #include <cmath>		// for ceil
> #include <cstdlib>		// 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?
>

You call your program with no arguments, which means that it returns 1,
which is interpreted as an error. Try returning 0 or fix the call so
that it goes through the path that returns 0.

Nick

      parent reply	other threads:[~2015-03-05 18:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-05 16:27 Capturing output from C/C++ Roger Mason
2015-03-05 18:00 ` John Kitchin
2015-03-05 18:06 ` Thierry Banel
2015-03-05 18:32 ` Nick Dokos [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ioefb8hl.fsf@alphaville.usersys.redhat.com \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).