www.digitalmars.com         C & C++   DMDScript  

c++.rtl - fgetc and charaacter "0D"

reply Casper <r.adres001 tiscali.nl> writes:
Hi All,

When I use fgetc from the "stdio.h" and I want to read a byte "0D" the 
function reads and gives the next character. As if all read bytes "0D" 
are always "Carriage Return".

I have three questions?

-If this is an known reaction, why is this not mentioned in the RTL 
documentation on the website? -And why does it not also skips the "0A" 
(Line feed) usually for windows systems?

-How can I let the fgetc read the "0D" as an byte?

I would like to see that this function gets an extra parameter of twin 
brother that both features can be used. (One that skips the "0D 0A" or 
"0D" and one that does not skips the 0D.

Regards,
Casper.
Nov 25 2007
parent reply Bertel Brander <bertel post4.tele.dk> writes:
Casper skrev:
 Hi All,
 
 When I use fgetc from the "stdio.h" and I want to read a byte "0D" the 
 function reads and gives the next character. As if all read bytes "0D" 
 are always "Carriage Return".
 
 I have three questions?
 
 -If this is an known reaction, why is this not mentioned in the RTL 
 documentation on the website? -And why does it not also skips the "0A" 
 (Line feed) usually for windows systems?
 
 -How can I let the fgetc read the "0D" as an byte?
 
 I would like to see that this function gets an extra parameter of twin 
 brother that both features can be used. (One that skips the "0D 0A" or 
 "0D" and one that does not skips the 0D.
fgetc is a standard function and can thus not be changed. How to handle 0D and 0A is determined by the mode used when the files are opened, use fopen("my.txt", "rb") if you want to have both 0D and 0A.
Nov 25 2007
parent Casper <r.adres001 tiscali.nl> writes:
Hi Bertel,

Thanks for the tip!
Indeed I looked it up in "The C Programming language" and the same 
description was given.
I still feel that some note should have been made in the documentation 
of this function, as well in "The C Programming Language" book as any 
other documentation.

It is always annoying when calling a function a certain way, an other 
function reacts differently.

Nevertheless thanks!

Regards,
Casper.

Bertel Brander wrote:
 Casper skrev:
 Hi All,

 When I use fgetc from the "stdio.h" and I want to read a byte "0D" the 
 function reads and gives the next character. As if all read bytes "0D" 
 are always "Carriage Return".

 I have three questions?

 -If this is an known reaction, why is this not mentioned in the RTL 
 documentation on the website? -And why does it not also skips the "0A" 
 (Line feed) usually for windows systems?

 -How can I let the fgetc read the "0D" as an byte?

 I would like to see that this function gets an extra parameter of twin 
 brother that both features can be used. (One that skips the "0D 0A" or 
 "0D" and one that does not skips the 0D.
fgetc is a standard function and can thus not be changed. How to handle 0D and 0A is determined by the mode used when the files are opened, use fopen("my.txt", "rb") if you want to have both 0D and 0A.
Nov 26 2007