View Single Post
Join Date: Jun 2008
Posts: 32
Reputation: salman213 is an unknown quantity at this point 
Solved Threads: 0
salman213 salman213 is offline Offline
Light Poster

Sending "char" to "int" variable

 
0
  #1
Nov 19th, 2008
Hi i have a question. Im using Dev C++ and this simple program takes in values of x and outputs *prints them on the screen. Although x should be an integer If i put in for example the letter "u" or any letter for that matter it goes on and on without asking me for anohter input and uses the last input on the screen. Why?

  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4. main()
  5. {
  6. int x=0;
  7. while (true)
  8. {
  9. scanf("%d",&x);
  10. printf("%d", x);
  11. }
  12.  
  13. }
Last edited by salman213; Nov 19th, 2008 at 10:12 pm.
Reply With Quote