cgccconio

How to add conio in Codeblocks?


I'm trying to build and run this code

#include<stdio.h>
#include<conio.h>

main()
{
textcolor(RED); 
cprintf("Hello, World!");

getch();
return 0;
}

I use code blocks - gcc compiler.As GCC doesn't support conio.h , i'm getting a lot of errors.I want to add a library which is needed for running this kind of programs. Being instructed by a blog I downloaded conio21 from this link: https://sourceforge.net/projects/conio/ but I can't find the libconio.a there.Can you please explain how to add the library?


Solution

  • Download and extract conio library that you link in your question. Inside of it take conio.c and conio2.h to your project folder. Then include conio2.h to your source code:

    #include<stdio.h>
    #include"conio2.h"
    
    main()
    {
        textcolor(RED); 
        cprintf("Hello, World!");
    
        getch();
        return 0;
    }
    

    I tested, it works.