简体   繁体   English

如何在Turbo C IDE中查看程序的输出?

[英]How can I see the output of my program in the Turbo C IDE?

How do I print #include<conio.h> in C 如何在C中打印#include<conio.h>

#include<stdio.h>
#include<conio.h>
void main()
{
printf("#include<conio.h>");

}

How to get the output as 如何获得输出为

#include<conio.h>

you have to put getch(); 你必须把getch(); and press Ctrl+f9 instead of alt+f5 然后按Ctrl + f9(而不是alt + f5)

I don't think you need to do anything else. 我认为您无需执行其他任何操作。 You have written the solution yourself. 您已经自己编写了解决方案。 All you have to do is just Compile and Run ......... :) 您所要做的只是CompileRun ......... :)

If you are running it from an IDE, you might need to look at the output console or something, and maybe it closes when your program quits before you get a chance to see what it has printed. 如果从IDE运行它,则可能需要查看输出控制台或其他内容,并且可能在程序退出时关闭它,然后才有机会查看其打印内容。

If you are running it from the command line, maybe (because it doesn't print a newline after the string) your prompt is clobbering the output. 如果从命令行运行它,则可能是(因为它在字符串后不显示换行符),因此提示提示正在破坏输出。

I think you have a great confusion between the GCC(GNU Compiler Collection) and turbo c compilers. 我认为您在GCC(GNU编译器集合)和turbo c编译器之间有很大的困惑。

In turbo C compilers the output will be stored separately in an output pane which can be viewed by pressing alt+F5 . 在Turbo C编译器中,输出将单独存储在输出窗格中,可通过按alt + F5进行查看。

So in order to view the page while compiling you need to enter an input in the output page so that the page exits only after typing an input. 因此,为了在编译时查看该页面,您需要在输出页面中输入一个输入,以便该页面仅在键入输入后退出。

For doing this we are using a function called getch(); 为此,我们使用了一个名为getch();的函数getch(); which is obtained from the conio.h library. 这是从conio.h库获得的。

Hence insert a getch(); 因此插入一个getch(); function after the printf statement and press ctrl+F9 . printf语句之后执行功能,然后按ctrl+F9 Now I hope the output is displayed. 现在我希望显示输出。

NOTE: - The output page might be displayed for other programs which contain a scanf statement so that you can give an input on the output page.But even then you cannot able to see the output produced by printf statements after the scanf by pressing Ctrl+F9. 注意:-对于包含scanf语句的其他程序,可能会显示输出页面,以便您可以在输出页面上进行输入。但是即使如此,您也无法通过按Ctrl +来查看scanf之后printf语句产生的输出F9。

If I remember Turbo C++ right (could be the same), you need to go to the Output window to see the result. 如果我没记错Turbo C ++(可能是一样的话),则需要转到“ Output窗口以查看结果。 So go to Window on the menu bar and select Output --- you should see your string there. 因此,转到菜单栏上的“ Window ”,然后选择“ Output ---”,您应该在那里看到您的字符串。

If that doesn't work add getch(); 如果这样不起作用,请添加getch(); to the end of your program. 到程序结尾 This will ensure that the program will wait for a keystroke from the user before exit. 这将确保程序在退出之前将等待用户的击键。

It works fine for me, but I suppose it's remotely possible that your STDOUT stream is not being flushed automatically. 它对我来说很好用,但是我认为您的STDOUT流没有自动刷新的可能性很小。 Try adding 尝试添加

fflush(stdout);

after the printf . printf

Sometimes the shell will overwrite the last printed line if it doesn't end in a newline; 有时,如果shell没有以换行符结尾,它将覆盖最后打印的行; try adding a \\n to the end of the printf 尝试在printf的末尾添加\\n

What if you replace the 'printf' call with 如果您将'printf'呼叫替换为

fprintf(stderr, "#include<conio.h>");

Or, try this: 或者,尝试以下操作:

_cprintf("#include<conio.h>");

Any luck? 运气好的话?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM