From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: patrol Newsgroups: gmane.emacs.help Subject: capturing user input for program run in Emacs? Date: Wed, 30 Jun 2010 11:47:28 -0700 (PDT) Organization: http://groups.google.com Message-ID: <7773694a-884f-4c7a-9356-847d792a89d7@q12g2000yqj.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1291840864 26476 80.91.229.12 (8 Dec 2010 20:41:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 20:41:04 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 08 21:41:00 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQQoU-0007Wh-Ss for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 21:41:00 +0100 Original-Received: from localhost ([127.0.0.1]:38948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQQjR-0002RA-Cf for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 15:35:21 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!q12g2000yqj.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 54 Original-NNTP-Posting-Host: 173.34.86.168 Original-X-Trace: posting.google.com 1277923648 25647 127.0.0.1 (30 Jun 2010 18:47:28 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 30 Jun 2010 18:47:28 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q12g2000yqj.googlegroups.com; posting-host=173.34.86.168; posting-account=tRtJWQkAAABbewN3eJi0F90kUywr8NrS User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; MathPlayer 2.10d; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3),gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:179379 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75992 Archived-At: 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 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