| Author |
Why this output in this I/O program?
|
John-Philippe Verger
Greenhorn
Joined: Feb 18, 2008
Posts: 22
|
|
Hi all,
I 've written this program :
In my file scjp.txt , I have typed the number 127 (it's all the content of the file scjp.txt).
When I run the program,I have this output :
49
50
55
I don't understand why I have this output. Please, why this output?
Thanks in advance for your answers.
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
dude its because you are printing the int value of the characters 1,2, and 7 which are 49,50and 55
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
if c was a character you would have got 127..but c here is a char
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
to be precise it had to be an array of char like char c[]..
|
 |
rohan yadav
Ranch Hand
Joined: Oct 13, 2009
Posts: 156
|
|
I think you should try this :
cast c to char will solve your problem
|
Sage of The Monstrous Toad of Mount Myoboku
|
 |
John-Philippe Verger
Greenhorn
Joined: Feb 18, 2008
Posts: 22
|
|
|
Thanks you very much Ankur Khotari and Rohan Yadav .
|
 |
 |
|
|
subject: Why this output in this I/O program?
|
|
|