Mail Archives: djgpp/1997/02/28/11:44:16
Neil Roy (royn AT usa DOT net) wrote:
: I am a beginner C programmer, I used to program in BASIC (QuickBasic
: and others) and have read "Moving from QBasic to C" (great book!) and
: will be reading a C++ book and then will be moving on to a rather
: lengthy book on game programming, the problem is, while the C and C++
: books properly teach you using ANSI C examples, the game programming
: book uses Microsoft C (7.0) examples and I was wondering if anyone out
: there had any tips/sugestions etc... on how I should go about converting
: the source code over. I know about "far", "near" etc... (or think I do,
: if you have any insights into that part of programming please let me
: know!) but after removing the "far" from the source, more often than
: not, the program simply will not execute properly (if at all). I
: usually get tons of compiler errors.
It's not that simple. You may have to rewrite parts of your code in
order to make it work. A small example of a typical case would be
helpful in helping you.
: Another problem I noticed with GNU/DJGPP is that after I compile and
: example program, say:
: printf("Enter your age:");
: scanf(" %d", &age);
: ...the prompt "Enter your age:" doesn't appear until the age is
: entered. I realize that scanf() is probably the worst way to get input,
: but just for examples and testing it should still print the printf()
: before the scanf(). Have I missed something here or is there a bug I
: have stumbled upon?
A fflush(stdout); after printf(...); should help. This is because stdout
is buffered so, without fflush, your prompt is printed only after you
press return at the end of input. If your C book doesn't say anything
about this, it's hardly worth reading ;-).
--
Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/
- Raw text -