2012-10-19 32 views
0

我想在emacs中使用powershell,但似乎emacs中的powershell是块缓冲的。例如,当我编写这样一个简单的C程序时:如何在Windows emacs中为powershell进行行缓冲

int main() 
{ 
printf("input the number of a value: \n"); 
scanf("%d", &num); 
} 

我编译它并使它在emacs下的Powershell中运行。直到我输入一个数字并输入Enter,它才会打印出行input the number of a value:。 c程序在emacs之外的powershell中运行良好。我的问题是如何运行emacs中缓冲的PowerShell产品线?

编辑我使用Powershell.el

回答

0

您的fscanf之前需要fflush

+0

当我在'fscanf'之前'fflush'时,它会刷新两次,并且有两个完全相同的输出。 – toolchainX

0

这对我的作品与eshell

#include <stdio.h> 

int main() { 
    int num; 
    printf("input the number:\n"); 
    fflush(stdout); 
    scanf("%d", &num); 
    printf("inc: %d\n", num + 1); 
} 

我无法重现powershell.el您的问题,因为我看到了另一个问题:它不会等待输入,“读取” 0代替,版画“ inc:1“并退出。

+0

是你的答案吗?或者你遇到同样的问题?我在powershell下的emacs中运行你的代码。它像你所描述的一样:它不等待输入,“读取”0代替,打印“inc:1”并退出。 – toolchainX

+0

它适用于'GNU Emacs for windows'中包含的程序cmdproxy,或许应该在powershell.el中完成 – toolchainX

+0

这是一个部分答案:问题中的代码的行为与编译时描述的完全相同,从'eshell'运行(我还必须声明'int num',否则它不会编译)。我发布的代码在'eshell'中运行,并且按照预期运行。 'powershell.el'的问题必须是一个单独的问题。 – Dmitry