program which terminate with X letter





#include
#include

char storage[80];

int main()
{
char c;
int index = 0;

printf("Enter any characters, terminate program with X\n");

do
{
c = _getch(); /* get a character */
if (index < 79) /* limit it to 79 characters */
{
storage[index] = c;
index++;
}
putchar(c); /* display the hit key */
} while (c != 'X');
storage[index] = 0;
printf("%s\n", storage);
printf("\nEnd of program.\n");

return 0;
}

No comments:

Post a Comment