Chasing paper and bytes...
Oct. 15th, 2002 09:00 pmThe paper chase continues. I had an illuminating conversation with my new CPA. There is light at the end of the tunnel. I just have to make sure I get everything done by the end of the month.
Period.
End of paragraph.
* * * As I was drifting off to sleep last night, I figured out what I needed to do to send a 16-bit integer (unsigned) to stdout one byte at a time:
unsigned int target = 0xfeff;
unsigned char *uc = ⌖
fputc(*uc++, stdout);
fputc(*uc, stdout);
It does the job. Hooray.
Now I am faced with another problem. Apparently, when I fputc() a carriage return character (0x0d), a linefeed is added (by the Microsoft OS?) automagically, or maybe not. In any event, when I try to output 0x000d to stdout, I see the following sequence in the file:
0x0d 0x0a 0x00
instead of:
0x0d 0x00 0x0a 0x00
The original file, like any good DOS text file, has embedded carriage returns followed by line feeds, which befuddles me further.
Hypothesis: when I call fgetc(stdin), if the read character is a carriage return, the following linefeed is ignored. If I write that character, then a following linefeed is appended.
I may have to go over to writing the output as a binary file, methinks.
Cheers...
Period.
End of paragraph.
unsigned int target = 0xfeff;
unsigned char *uc = ⌖
fputc(*uc++, stdout);
fputc(*uc, stdout);
It does the job. Hooray.
Now I am faced with another problem. Apparently, when I fputc() a carriage return character (0x0d), a linefeed is added (by the Microsoft OS?) automagically, or maybe not. In any event, when I try to output 0x000d to stdout, I see the following sequence in the file:
0x0d 0x0a 0x00
instead of:
0x0d 0x00 0x0a 0x00
The original file, like any good DOS text file, has embedded carriage returns followed by line feeds, which befuddles me further.
Hypothesis: when I call fgetc(stdin), if the read character is a carriage return, the following linefeed is ignored. If I write that character, then a following linefeed is appended.
I may have to go over to writing the output as a binary file, methinks.
Cheers...