Help needed !!!!!!!!!!!!!!!!

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Mar 2009
Posts: 8
Reputation: PRATS 1990 is an unknown quantity at this point 
Solved Threads: 0
PRATS 1990's Avatar
PRATS 1990 PRATS 1990 is offline Offline
Newbie Poster

Help needed !!!!!!!!!!!!!!!!

 
0
  #1
Mar 23rd, 2009
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????????????????????????????????
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4.  
  5. main()
  6. {
  7. char a;
  8. clrscr();
  9. printf("enter any character\n");
  10. scanf("%c",&a);
  11. printf("the ascii code of %c is %d",a,a);
  12. getch();
  13. }
THANK YOU,,,,,,,,,,,,,,,,,,,,,
Last edited by Ancient Dragon; Mar 23rd, 2009 at 3:18 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,038
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: Help needed !!!!!!!!!!!!!!!!

 
0
  #2
Mar 23rd, 2009
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.
Last edited by Aia; Mar 23rd, 2009 at 12:04 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,978
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 288
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: Help needed !!!!!!!!!!!!!!!!

 
0
  #3
Mar 23rd, 2009
DON'T SHOUT SO LOUD!
I have delicate ears you know...
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: PRATS 1990 is an unknown quantity at this point 
Solved Threads: 0
PRATS 1990's Avatar
PRATS 1990 PRATS 1990 is offline Offline
Newbie Poster

Re: Help needed !!!!!!!!!!!!!!!!

 
-1
  #4
Mar 23rd, 2009
Sorry guys didn't know that all caps means yelling as far as ,,,,,,,,,,,,,,,,!!!!!!!!!!!!!????????????????? go its just my style!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 251
Reputation: ssharish2005 is on a distinguished road 
Solved Threads: 20
ssharish2005's Avatar
ssharish2005 ssharish2005 is offline Offline
Posting Whiz in Training

Re: Help needed !!!!!!!!!!!!!!!!

 
0
  #5
Mar 23rd, 2009
Originally Posted by PRATS 1990 View Post
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????????????????????????????????
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4.  
  5. main()
  6. {
  7. char a;
  8. clrscr();
  9. printf("enter any character\n");
  10. scanf("%c",&a);
  11. printf("the ascii code of %c is %d",a,a);
  12. getch();
  13. }
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!

  1. void clear_buffer( void )
  2. {
  3. int ch;
  4. while( ( ch = getchar() ) != '\n' && ch != EOF );
  5. }

-ssharish
"Any fool can know, point is to understand"
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 8
Reputation: PRATS 1990 is an unknown quantity at this point 
Solved Threads: 0
PRATS 1990's Avatar
PRATS 1990 PRATS 1990 is offline Offline
Newbie Poster

Re: Help needed !!!!!!!!!!!!!!!!

 
0
  #6
Mar 24th, 2009
THANK U

ssharish2005
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC