Thread: pls help urgently

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    15

    pls help urgently

    Code:
    #include<stdio.h>
    
    /* program to calculate no of tabs,spaces,tabs alongwith characters */
    
    int main(){
    int c;
    int nc,nspc,ntb,nline;
    
    nc=nspc=ntb=nline=0;
    c='\0';
    
    while((c=getchar())!=EOF){
    ++nc;
    
    if(c == ' ')
    ++nspc;
    else if(c=='\t')
    ++ntb;
    else if(c=='\n')
    ++nline;
    else;
    }
    
    printf("\ncharacters:%d\tspace:%d\ttabs:%d\tNewlines:%d\t",nc,nspc,ntb,nline);
    return 0;
    }
    i can't find the bug here..i've used a MinGW gcc compiler on a windows machine..

    the program compiles correctly...i give it ctrl+c as a end of file indicator..

    the programs runs fine the first time..but start giving problems..after wards..sometimes the second last (printf) statement is not executed @ ctrl+c combination...
    other times the printf statement contains all 0 zero values ..pls help
    Last edited by rickyspaceguy; 09-25-2009 at 03:25 PM. Reason: clarification

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i dont know what to do. pls. help!!!!
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 03-14-2002, 03:24 PM
  2. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 10:46 AM
  3. C programming - pls pls help me
    By sally arnold in forum C Programming
    Replies: 10
    Last Post: 01-16-2002, 04:55 AM
  4. pls help me!!
    By hanseler in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2001, 08:46 PM
  5. Pls Help Me In This Question!!!
    By Joanna in forum Windows Programming
    Replies: 1
    Last Post: 10-20-2001, 02:05 PM