LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 707|回复: 2

A question about running C program in Emacs

[复制链接]
发表于 2007-4-1 16:06:02 | 显示全部楼层 |阅读模式
Hi, all.
I am learning the C language.
I'd like to edit the code in emacs.
It is my question-----as shown in the eg.
  1. //test.c
  2. /*Program to find the greatest common divesor
  3. of two nonnegative interger cvalues */
  4. #include<stdio.h>
  5. int main(void)
  6. {
  7.   int u,v,temp;
  8.   printf("Please type in two nonnegative interger.\n");
  9.   scanf("%i%i",&u,&v);
  10.   while(v!=0){
  11.     temp=u%v;
  12.     u=v;
  13.     v=temp;
  14.   }
  15.   printf("Their greatest common divisor is %i\n",u);
  16.   return 0;
  17. }
复制代码

I compile the file by shell command in emacs(M-!)
gcc -o test test.c

and then run the executable file by shell command---just like the above
./test

but the message appears:
Please type in two nonnegative interger.
Their greatest common divisor is 1

It seems that I have no chance to input the two intergers. Why?

When I run the executable by terminal, it works well.

Soory for E, no input method.
发表于 2007-4-1 20:07:42 | 显示全部楼层
的确是这样,我都是M-x shell再./test的。
一直觉得那个M!不是个交互界面,只是你把命令传给它,它再把结果传给一个buffer而已。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-4-1 20:23:56 | 显示全部楼层
嗯,这样不错,直接在emacs中创建一个shell buffer,可以的。
免得我再回到另外一个terminal了。
谢谢啦 。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表