counting characters program in c

Posted by mena on Stack Overflow See other posts from Stack Overflow or by mena
Published on 2010-05-17T14:12:41Z Indexed on 2010/05/17 14:20 UTC
Read the original article Hit count: 152

Filed under:

Hello, the output of characters number is the actual no. plus 3 i don't know why?

This is the code:



void main(void)
{

 int ch,w=0,c=0;
 do
 {
  ch=getche();
  ++c;
  if(ch==32)
  {
      ++w;
      ++c;
  }

 }while(ch!=13);
 printf("\nnum of characters is  %d",c);
 printf("\nnum of words is  %d",w);
        getch();
}

© Stack Overflow or respective owner

Related posts about c