C program not executing more than once

Discussion in 'C Programming' started by satya123, Mar 24, 2011.

  1. satya123

    satya123

    Joined:
    Jul 6, 2010
    Messages:
    6
    Likes Received:
    0
    Hi all,

    I have written the following code for displaying the characters which are more than 20 characters

    /* Write a program to print all input lines that
    are longer than 20 characters */

    #include <stdio.h>
    int main()
    {
    int c;
    unsigned int nw=0;
    char array[100];

    while((c = getchar()) != EOF)
    {
    array[nw] = c;
    nw++;

    if(c == '\n')
    {
    if(nw >= 20)
    {
    array[nw] = '\0';
    printf("%s",array);
    nw=0;
    }
    else
    {
    printf("Sorry less than 20 Char\n");
    nw=0;
    }
    }
    }
    return 0;
    }

    i have compiled the above program in command prompt using the command tcc test.c the compiler then generates test.exe file. For the first time if i type test it gives me the expected output, but if i run the program again by typing test, the program does not run. i need to recompile the program again to execute the program. could somebody help me on this?

    Thanks
    satya
     
    satya123, Mar 24, 2011
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. googler
    Replies:
    4
    Views:
    715
    usenet_10@stanka-web.de
    Jun 1, 2005
  2. Vinod I
    Replies:
    3
    Views:
    532
    Kelly Leahy
    Jan 16, 2004
  3. Todd Krein

    Can't run BLT program more than once?

    Todd Krein, Apr 28, 2005, in forum: Python
    Replies:
    0
    Views:
    438
    Todd Krein
    Apr 28, 2005
  4. Christopher Subich
    Replies:
    4
    Views:
    772
    Christopher Subich
    Jun 12, 2005
  5. lds
    Replies:
    0
    Views:
    471
  6. Steven Woody

    Can not `setlocale(3)' more than once in Linux

    Steven Woody, Apr 25, 2008, in forum: C Programming
    Replies:
    7
    Views:
    990
    Steven Woody
    Apr 28, 2008
  7. Gancy
    Replies:
    4
    Views:
    466
    Rasto Levrinc
    Feb 3, 2005
  8. dec135@msn.com
    Replies:
    3
    Views:
    267
    Gary Herron
    Dec 23, 2013
Loading...