Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
November 25, 2007 fgetc and charaacter "0D" | ||||
---|---|---|---|---|
| ||||
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. |
November 25, 2007 Re: fgetc and charaacter "0D" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Casper | 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.
|
November 26, 2007 Re: fgetc and character "0D" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bertel Brander | 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.
>
|
Copyright © 1999-2021 by the D Language Foundation