C program not executing more than once


Joined
Jul 6, 2010
Messages
6
Reaction score
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
 
Ad

Advertisements


Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top