all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: patrol <patrol_boat@hotmail.com>
To: help-gnu-emacs@gnu.org
Subject: capturing user input for program run in Emacs?
Date: Wed, 30 Jun 2010 11:47:28 -0700 (PDT)	[thread overview]
Message-ID: <7773694a-884f-4c7a-9356-847d792a89d7@q12g2000yqj.googlegroups.com> (raw)

Hi,

I ran a simple C program from within Emacs using the shell command
(M-!). The program requires user input.

Here's the program:

#include <stdio.h>

char firstInitial, middleInitial, lastInitial;
int age;

main()
{
  printf("Input your three initials (first, middle, and last) and your
age:   ");
  scanf("%c%c%c%i", &firstInitial, &middleInitial, &lastInitial,
&age);
  printf("\nGreetings %c.%c.%c. %s %i.\n",
	 firstInitial, middleInitial, lastInitial,
	 "Next year your age will be", age + 1);
}

And this is the output I get:

Input your three initials (first, middle, and last) and your age:   ^M

Greetings ^@.^@.^@. Next year your age will be 1. ^M

The program just outputs this and doesn't stop to give me a chance to
input the information. I believe the ^M stands for RET, so it looks
like Emacs is somehow automatically "feeding RET" to the program, I'm
guessing??? And I have no idea what ^@ means.

I also tried starting a separate subshell using M-x shell. It works
"better", but still not right. When I activate the program by typing
its filename (which is Initials), I don't see the user prompt (i.e.,
"Input your three initials..."). It just reprints the file name like
so:

c:\cprograms>Initials
Initials

So then I do the input anyway (e.g., ABC30), press RET, then I get:

Input your three initials (first, middle, and last) and your age:
Greetings A.B.C. Next year your age will be 31.

So, I guess it's kind of working, but the user input part is still
messed up. Incidentally, the program works fine from the console
(command) prompt, but I'd like to be able to run it from within Emacs,
too. Can anyone tell me what the problem is?

Thanks


             reply	other threads:[~2010-06-30 18:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-30 18:47 patrol [this message]
2010-06-30 22:28 ` capturing user input for program run in Emacs? Tim X

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

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

  git send-email \
    --in-reply-to=7773694a-884f-4c7a-9356-847d792a89d7@q12g2000yqj.googlegroups.com \
    --to=patrol_boat@hotmail.com \
    --cc=help-gnu-emacs@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.