FILE I/O & SLOW WINDOWS
Ken Konecki
kk at richp1.UUCP
Wed Feb 10 23:58:32 AEST 1988
In article <11678 at brl-adm.ARPA> VC008329%NDSUVM1.BITNET at cunyvm.cuny.EDU (MITCHELL L GRAVES) writes:
>
> I have been using Turbo C for anly a few months now and I'm having a couple
>of problems with a program I'm writing.
>
...After using fgets() there is a printf:
> printf("Password is: |%s|",&password);
>
>This is what it looks like when I print password:
>
>Password is: |ORANGE
>|
The reason is fgets(buf,n,stream) keeps the newline character if it reads one.
You can remove it easily by adding this line:
fgets(buf,n,stream); /* your specific fgets goes here */
buf[strlen(buf)-1] = '\0'; /* ZAP that newline */
>
>Problem Two:
>
>I am drawing windows on the screen when prompting for passwords & things
>of that nature. I can watch the window being drawn (Very Sloooww!). I heard
>there is a way to write the screen to a buffer (or something like that) and
>later call it up so I don't have to watch the window being slowly drawn each
>time. Can anyone help me out?
(Under the assumption you're using and IBM PC or AT and you're using
text mode to do your painting.)
I've never done this in Turbo C, but used to do it in Turbo PASCAL all the
time. To write the screen the screen to a buffer just copy the screen
memory to your buffer and to put it back, just reverse the process.
Monochrome screen memory begins at 0xB000:0x0000 (segment:offset)
and color memory begins at 0xB800:0x0000 (segment:offset). All you have
to do is set a pointer to the beginning of the right kind of memory
(you can find out if you have a color or monochrome from a BIOS call,
but I don't know which offhand) and do a memcpy(buf,screen,4000) to
save the entire screen and memcpy(screen,buf,4000) to restore it.
If you need more help, just send me e-mail (address is ihnp4!richp1!kk).
--
Ken Konecki @ ihnp4!richp1!kk
"A squeegee by any other name wouldn't sound as funny"
More information about the Comp.lang.c
mailing list