I HAVE A VERY PECULIAR PROBLEM,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,


THE PROGRAMS I COMPILE SHUT DOWN AFTER COMPILING ONCE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

FOR EG-
I CREATED THIS PROGRAM FOR GETTING THE ASCII CODES OF AN ALPHABET ,,,,,,,,,,,,,,,,,,
AFTER I WROTE THE ALPHABET IN DOS IT DISPLAYED ITS VALUE AND SHUTDOWN,,,,,,,,,,,,,,,,
HOW CAN I ALTER MY PROGRAM TO TAKE IN AS MANY VALUES AS I WANT????????????????????????????????

#include<stdio.h>
#include<conio.h>


main()
{
char a;
clrscr();
printf("enter any character\n");
scanf("%c",&a);
printf("the ascii code of %c is %d",a,a);
getch();
}

THANK YOU,,,,,,,,,,,,,,,,,,,,,

Is your keyboard broken? It looks like sticky key with (!), (,) and (?).
Do you know that ALL caps represents YELLING! Not cool! Stop yelling at people you don't even know.

Learn how to use a loop, and include the scanf() inside one.

Sorry guys didn't know that all caps means yelling as far as ,,,,,,,,,,,,,,,,!!!!!!!!!!!!!????????????????? go its just my style!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Comments
Well, your 'style' is irritating.

I HAVE A VERY PECULIAR PROBLEM,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,


THE PROGRAMS I COMPILE SHUT DOWN AFTER COMPILING ONCE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

FOR EG-
I CREATED THIS PROGRAM FOR GETTING THE ASCII CODES OF AN ALPHABET ,,,,,,,,,,,,,,,,,,
AFTER I WROTE THE ALPHABET IN DOS IT DISPLAYED ITS VALUE AND SHUTDOWN,,,,,,,,,,,,,,,,
HOW CAN I ALTER MY PROGRAM TO TAKE IN AS MANY VALUES AS I WANT????????????????????????????????

#include<stdio.h>
#include<conio.h>


main()
{
char a;
clrscr();
printf("enter any character\n");
scanf("%c",&a);
printf("the ascii code of %c is %d",a,a);
getch();
}

THANK YOU,,,,,,,,,,,,,,,,,,,,,

Well, that because you used the scanf function to read the value. The quick solution for this is to place two getch or getchar()! Or you will have to call the following function just above the getch() function or everything you read a char you will have to call this function before you read. That makes sure that the input buffer is clear and program won't shutdown!

void clear_buffer( void )
{
     int ch;
     while( ( ch = getchar() ) != '\n' && ch != EOF );
}

-ssharish

This question has already been answered. Start a new discussion instead.