I am using Microsoft Visual C++ V6.0 Standard Edition to compile the C code below as a standard console application. But when I run the code in the console and type some text the printf() function will not work for me when printf() is the outside of the While loop the way I have it below. Only when I move the printf() inside the While loop will I get a result. Can anyone tell me what I am doing wrong? This problem also happens when I try to use putchar(). My email is JCSeven@aol.com.
JoeCode:/* This is a program to count blanks, tabs, and newlines */ #include <stdio.h> void main() { int nb, nt, nl, c; nb = 0; nt = 0; nl = 0; while ((c = getchar()) != EOF) { if (c == ' ') ++nb; if (c == '\t') ++nt; if (c == '\n') ++nl; } printf("%d %d %d\n", nb, nt, nl); }



LinkBack URL
About LinkBacks



)