Date: Thu, 25 Nov 2004 20:29:17 -0600 (CST) From: David Fleck <david.fleck@mchsi.com> To: Tom Parquette <BCSFD204@twcny.rr.com> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Re: OT: Trying to learn C -- some questions Message-ID: <20041125202210.O48346@grond.sourballs.org> In-Reply-To: <41A67AF2.1060803@twcny.rr.com> References: <41A67AF2.1060803@twcny.rr.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 25 Nov 2004, Tom Parquette wrote: > 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 think they are probably wrong. > 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? I don't know if it's a DOSism, but it's definitely not a standard header file in the UNIX world. I've never encountered it outside of Microsoft systems. > 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. Sorry, not sure about this, but again, it sounds like a DOS (or MS) specific implementation. > 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. 'gets()' will still work, but its use isn't advised. If you're just using it in test programs, though, it's not a big deal. > 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? I think the real problem hear is that the getch() the example is referencing is actually a function found in conio.h. The getch() in curses probably isn't the one you want anyway. (Ref.: http://lists.apple.com/archives/mpw-dev/2001/Aug/msg00182.html) -- David Fleck david.fleck@mchsi.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041125202210.O48346>