• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why this output in this I/O program?

 
John-Philippe Verger
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if c was a character you would have got 127..but c here is a char
 
Ankur kothari
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to be precise it had to be an array of char like char c[]..
 
rohan yadav
Ranch Hand
Posts: 156
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you should try this :


cast c to char will solve your problem
 
John-Philippe Verger
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you very much Ankur Khotari and Rohan Yadav .
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic