-3

This is for programming in C:

I want to download conio.h in Virtualbox on my mac computer, however, after I downloaded it which was from here: https://sourceforge.net/projects/myconio/, I began receiving errors such that it couldn't find specific files. Is there another place I can download conio.h from or is there a way I can fix the errors I am receiving?

Also, I am making a quiz game for which I want to create a GUI (Graphic User Interface). How would I be able to do this in Virtualbox so that I don't have the game appear in terminal but in a separate GUI?

user1049876
  • 117
  • 1
  • 3
  • 18
  • conio is very old. If you want to use it you'll likely need to use an old compiler that came with it. It's also only for terminal based programs. If you want to learn a gui you might look at something like Qt. – Retired Ninja Jul 12 '16 at 16:31
  • I do not quite get what your are trying to do. So your host computer is a mac right? Now you have a virtual machine installed (I guess it is a windows)? And now you are missing conio.h? – mame98 Jul 12 '16 at 16:32
  • If the compiler does not provide `conio.h` then it won't have the library to link either. – Weather Vane Jul 12 '16 at 16:33
  • Anyways, this SO questing seems to be related: http://stackoverflow.com/questions/25167605/conio-h-is-missing-from-windows – mame98 Jul 12 '16 at 16:34
  • @RetiredNinja I looked up Qt online and will give it a try. – user1049876 Jul 12 '16 at 16:41
  • @mame98 that is correct. I want to use getch() which seems only to be used on conio.h – user1049876 Jul 12 '16 at 16:42

2 Answers2

1

conio.h is a header that worked only on very old compilers, older than the C89 standard. You cannot use that thing for any kinds of GUI. The compilers themselves don't work on modern systems (only 32-bit versions of Windows can run 16-bit DOS apps)

The thing is, there is nothing real that compensates for what is missing in conio.h.

Note: In Code::Blocks I noticed that some versions accept _getch instead of getch as a function name. Other functions don't work. Even this one is not really standard.

Paul Stelian
  • 1,381
  • 9
  • 27
  • When I used `_getch()`, I got errors such as warning: the 'gets' function is dangerous and should not be used. & undefined reference to '_getch' & more undefined references to '_getch' follow collect2: & error: ld returned 1 exit status – user1049876 Jul 12 '16 at 18:54
  • Then the function doesn't exist and you must find some alternative. If neither the getch nor the _getch functions work. You may use something in windows.h (I did that at some time), or you may not try to make commandline programs work like that. – Paul Stelian Jul 12 '16 at 18:55
  • 1
    getchar is not in real time and should not trigger a gets warning (you did not also use gets somewhere else, did you?) There is no real, portable way to read single characters from the console now, besides getchar (which will read them once you actually press Enter and will be a mess) – Paul Stelian Jul 12 '16 at 18:59
  • 1
    I am no longer getting the error, it was because of something else I put in the code. But I do want to ask about what you mean when you say "There is no real, portable way to read single characters from the console now". – user1049876 Jul 12 '16 at 19:03
  • Well, getch/_getch won't work on non-Windows systems. The POSIX functions read()/write()/... won't work on Windows. getchar() is the only thing that does character-by-character input, but it still isn't quite perfect due to buffering (you only get the characters once the user has inputted an entire line) – Paul Stelian Jul 12 '16 at 19:05
  • Do you mind explaining the buffering a little more? I am getting [sh: 1: cls: not found] and then after saying [Segmentation fault(core dumped)]. This error could be entirely separate from the `getchar()`, but I still want to understand what the buffering will do to my code. I appreciate your help! – user1049876 Jul 12 '16 at 19:11
  • @PailStelian I do think the error is separate from `getchar()` now that I look at my code. – user1049876 Jul 12 '16 at 19:12
  • Well, the program won't read everything you type from the console, but the console will, and whatever the program did not read will reach the shell. – Paul Stelian Jul 12 '16 at 19:13
  • For the segmentation fault, I need to see the full code. – Paul Stelian Jul 12 '16 at 19:13
  • Not as a comment. Instead link to the code or edit the question. – Paul Stelian Jul 12 '16 at 19:19
  • I know the code is long (i posted in the question) but I took a lot of suggestions from the internet. Suggestions meaning I looked at other peoples questions from online and implemented into my code or I looked on other cites. This is my first time asking a question myself on this topic. (the conio.h) – user1049876 Jul 12 '16 at 19:25
  • Okay, the code is really unwieldy, to begin with. Another thing is that without some direct keyboard access (getchar does NOT count) the game is as good as unusable. – Paul Stelian Jul 12 '16 at 19:28
  • The questions should probably be separate from the code itself. Separate code from data. – Paul Stelian Jul 12 '16 at 19:29
  • Ok, you mean in a separate .txt file? – user1049876 Jul 12 '16 at 19:32
  • Not neccesarily, but if you can do that, even better. You may also define the string constants and the array of questions somewhere in the program and use it later. – Paul Stelian Jul 12 '16 at 19:35
  • 1
    Thank you for your patience and your time, I will try your suggestion. – user1049876 Jul 12 '16 at 19:38
0

I see that this (a Linux implementation of the conio.h header) may be useful if you really want to use conio.h. It won't work on Windows, but on Linux it will work the same way it worked on Borland/Turbo C++ on DOS.

Paul Stelian
  • 1,381
  • 9
  • 27