简体   繁体   English

如果必须终止控制台,如何查看Visual Studio的输出?

[英]How can i see the output of the Visual Studio if i have to terminate the console?

I have to count the digits, white spaces and other characters in C using Visual Studio 2013. So, i input something and then i have to recive the output. 我必须使用Visual Studio 2013计算C中的数字,空格和其他字符。因此,我输入了一些内容,然后必须获取输出。 The problem is that i don't know how to exit the 'inputting' mode. 问题是我不知道如何退出“输入”模式。 All i can do is input text from keyboard or close the console. 我所能做的就是从键盘输入文本或关闭控制台。

Notes: 笔记:

  • I am using Console Application, i've tried Windows Application but no luck 我正在使用控制台应用程序,我尝试过Windows应用程序,但是没有运气
  • I've tried with and without Debug. 我已经尝试过和没有调试。
  • In Eclipse this exact code is working 在Eclipse中,此确切的代码正在运行
  • I've tried using Ctrl+Z 我尝试使用Ctrl + Z

Eclipse example: Eclipse示例:

He has 10 apples 他有10个苹果

digits = 1 1 0 0 0 0 0 0 0 0 , white space = 4, other= 11 位数= 1 1 0 0 0 0 0 0 0 0,空格= 4,其他= 11

main(){

int c, i, nwhite, nother;
int ndigit[10];

nwhite = nother = 0;

for (i = 0; i < 10; ++i)
    ndigit[i] = 0;

while ((c = getchar()) != EOF)
    if (c >= '0' && c <= '9')
        ++ndigit[c - '0'];
    else if (c == ' ' || c == '\n' || c == '\t')
        ++nwhite;
    else
        ++nother;

printf("digits = ");
for (i = 0; i < 10; i++)
    printf("%d ", ndigit[i]);

printf(", white space = %d, other= %d", nwhite, nother);
getchar();
return 0;
}
while ((c = getchar()) != EOF)

这样,停止输入的唯一方法是按Ctrl + Z,然后按Enter。

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

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