Re: C or C++ streams question



"Bill Cunningham" <nospam@xxxxxxxxx> writes:
I have an x86 boot sector that I can easily use cat boot.s >dev/fd0 or
cdrom to write a master boot record. Now how would one write a small program
in C/C++ to take 512B or 4096 bits to be more exact and write a string of
ascii characters of 1 and 0 using fgetc fputc ? I am guessing string.h would
be needed and of course fstream in C++. Though C++ is soo much simpler than
C C is well know for its low level abilities.

#v+
#include <stdio.h>
int main(void) {
int i = 0, c;
do {
c = fgetc(stdin);
} while (++i<512 && c!=EOF);
fputc('1', stdout);
fputc('0', stdout);
return 0;
}
#v-

Takes 512 bytes of data (unless there was an EOF) and prits string of
scii characters 1 and 0 (a character '1' followed by character '0').

So now, can you say what you really want so that everyone will
understand?

--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--
.



Relevant Pages

  • [NT] Argon Client Management Services Directory Traversal
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... int timeout; ... u_short port = PORT; ... if local_file is equal to %s will be used stdout for ...
    (Securiteam)
  • [NT] 2X ThinClientServer Directory Traversal
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... int timeout; ... u_short port = PORT; ... if local_file is equal to %s will be used stdout for ...
    (Securiteam)
  • [NT] BootManage TFTPD Buffer Overflow
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... is "a TFTP server for Windows implemented in BootManage Administrator". ... int timeout; ... if local_file is equal to %s will be used stdout for ...
    (Securiteam)
  • [NT] LANDesk Management Suite Directory Traversal
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... int timeout; ... u_short port = PORT; ... if local_file is equal to %s will be used stdout for ...
    (Securiteam)
  • Re: printf headache
    ... printf is fprintf to stdout? ... I'm curious why I don't see more fprintf. ... int", %ul prints an "unsigned int" followed by the l character, it is ... Keith and pete were discussing how to write the actual name ...
    (comp.lang.c)