Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type & learn C ___ a book I bought cheap to learn C. Help?

Status
Not open for further replies.

bronyrstomp

Technical User
Aug 12, 2001
11
CA
I am teaching myself unix and also C and C++ on FreeBSD.
The problem I have with this book is, it has an INCLUDE file that unix does not use.
#include <conio.h>
Ok, so I don't use it.
It also has this function in every program listed in the lessons.
It comes right after the #includes and before int main().
Here it is.
Code:
 char Pause(void)
{
    char c;
    printf(&quot;/nPress Enter to continue...&quot;);
    while ((c = getchar()) != '/n') {}
    return c;
}
I get an error when this is compiled in the program.
Is it part of the <conio.h> file?
Is it a Borland only function?
I am really new to this programming so I hope a chuckle is in order.
 
conio.h is DOS and Win32 (partially) compatible.
You need to use 'curses' library on Unix-like
systems. For example, ncurses.h is used on Linux.
But functions contained in that library is quite
differnt from conio.h.
Hee S. Chung
heesc@netian.com
 
Here getchar() is the culprit which belongs to conio.h on DOS Compilers; try using curses.h on *nix OS As far as I remember getchar is in <curses.h>

Hope that helps.
SwapSawe
 
Under Unix (as part of ANSI C), getchar() is part of <stdio.h>. You could comment out <conio.h>, as it is not used by this function.

The one problem I see that will produce an error, is that you used an escape sequence incorrectly:

while ((c = getchar()) != '/n') {}

should be:
while ((c = getchar()) != '\n') {}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top