dimanche 19 avril 2015

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. 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

  • I've tried with and without Debug.

  • In Eclipse this exact code is working


Eclipse example:


He has 10 apples


digits = 1 1 0 0 0 0 0 0 0 0 , white space = 4, other= 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;
}

Aucun commentaire:

Enregistrer un commentaire