Home > Enterprise >  How do I use conio.h and dos.h with gcc?
How do I use conio.h and dos.h with gcc?

Time:12-03

I want to learn C and I using YouTube, but there in code are modules conio.h and dos.h. But GCC don't knows them. Which whit the same functions I can use? (Any from another questions about this don't solving my problem)

I tried remove conio.h from code, but in the code, I have functions from it. That same with dos.h. After that, my text editor offered to me module coco_conio.h. What is that?

Functions , that I think that are from conio.h and dos.h:

#include <conio.h>
#include <dos.h>
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;
void setcursor(bool visible, DWORD size) {
CONSOLE_CURSOR_INFO lpcursor;
lpCursor.bvisible = visible;
lpCursor.dwSize = size;
SetConsoleCursorInfo(console, &lpCursor);
getch();
if(kbhit()) {

CodePudding user response:

This code here is a mix of the Windows API and old MS DOS libraries for the Borland Turbo compilers from 1989. You should be studying neither if your goal is to learn C . gcc/mingw only supports Windows, not MS DOS nor 30 year old Borland-specific libraries.

General advise:

  • Don't search for knowledge or wisdom on Youtube.
  • Reading books or taking classes are still the best bets for obtaining relevant and correct knowledge.
  • If you are new to programming then starting with C is a poor choice, since it's by far the most complex programming language out there. Python, Java or C# might be more suitable as first language.
  • Study object-orientated design at the same time as you are learning programming.
  • Learning C before C isn't a bad idea since C is largely based on C and the languages have lots of similarities.
  • Related