OT: Trying to learn C -- some questions

Tom Parquette BCSFD204 at twcny.rr.com
Thu Nov 25 16:45:43 PST 2004


Hi.  This is a little off topic but I'm hoping someone can provide some 
guidance and answer a few questions.  TIA.

I'm trying to learn ANSI C using a book circa 1994.  It is written from 
a DOS perspective.
Someone at work, who knows a little C, told me that the book was "close 
enough".
I'm having some trouble with some of the "homework" in the book.
I think I know some of the answers but I would like to confirm my 
understanding.
Some of the following I have no clue about.

1) gcc complains that <conio.h> was not found.  If I comment out the 
#include, the program compiles.  Is this a DOSism or something else?

2) fprintf is described with stdprn being valid for a default printer. 
This does not seem to be valid in, at least, the FreeBSD world.  man 
fprintf did not really help.  I believe I have to create a stream for 
the print but I'm not clear on how to do it.

3) gets() is used in a number of places.  Using this gets me:
/var/tmp//cciWrf9n.o(.text+0x20d): In function `get_data':
: warning: warning: this program uses gets(), which is unsafe.
I looked at the man page and found fgets.  I do not understand from the 
fgets man page how I'm supposed to code this.  I've tried a number of 
things along the lines of
fgets(rec.fname,sizeof(rec.fname));
but gcc does not like anything I've tried.  It keeps telling me I have 
"too few arguments fo function `fgets'"  Help!

4) A couple of the home work assignments use getch().  I figured out 
from the getch man page that I needed "#include <curses.h>" but that 
changes the errors to:
/var/tmp//cc1GEzyG.o(.text+0x6a): In function `main':
: undefined reference to `stdscr'
/var/tmp//cc1GEzyG.o(.text+0x6f): In function `main':
: undefined reference to `wgetch'
I do not know what header file I should be including.
Or is there something else I'm not understanding?

Thanks...


More information about the freebsd-questions mailing list