Hey

I rather not use conio.h for cross compatibility so is there any way to make my own "conio.h" and just include it in my compilation.

Thanks.

Recommended Answers

All 8 Replies

>I rather not use conio.h for cross compatibility
Good idea.

>is there any way to make my own "conio.h" and just include it in my compilation
Um, conio.h offers functionality that's non-portable by nature. No matter how you do it, you'll end up rewriting your replacement for every target to maintain portability. Is it possible to reproduce the functionality of conio.h? Absolutely, but all of those methods are (surprise surprise!) non-portable. Thus, you're right back where you started.

My usual recommendation with conio.h is to seriously consider whether it's needed in your program. Most of the time it's not.

>I rather not use conio.h for cross compatibility
Good idea.

>is there any way to make my own "conio.h" and just include it in my compilation
Um, conio.h offers functionality that's non-portable by nature. No matter how you do it, you'll end up rewriting your replacement for every target to maintain portability. Is it possible to reproduce the functionality of conio.h? Absolutely, but all of those methods are (surprise surprise!) non-portable. Thus, you're right back where you started.

My usual recommendation with conio.h is to seriously consider whether it's needed in your program. Most of the time it's not.

I personally wanted to use getch and getche

I personally wanted to use getch and getche

forget getch and getche ever existed. the need for unbuffered terminal input has become obviated since the widespread adoption of GUIs, like, about 15 to 20 years ago.


or dont, and hobble yourself with reliance on non-standard, non-portable library functions that will render your code unusable on most systems other than your own.


.

forget getch and getche ever existed. the need for unbuffered terminal input has become obviated since the widespread adoption of GUIs, like, about 15 to 20 years ago.


or dont, and hobble yourself with reliance on non-standard, non-portable library functions that will render your code unusable on most systems other than your own.


.

This is a small project for school but I perfer that it stay standard so it can run on Windows, OSX, and Linux as I on a personal level use Windows AND Linux.

Does ncurses for Windows exist?

This is a small project for school but I perfer that it stay standard so it can run on Windows, OSX, and Linux as I on a personal level use Windows AND Linux.

If so, just use getchar() . It's completely standard, All compilers know about it, it's totally portable.

This is a small project for school but I perfer that it stay standard so it can run on Windows, OSX, and Linux as I on a personal level use Windows AND Linux.

then stay away from "conio" or any similar libraries. otherwise trying to maintain cross-platform portability you're going to have a LOT of extra work. and by "a LOT" i really mean A LOT.

Now some program functions are worth that extra effort. But conio -- with its blinky screen text, colors, and unbuffered keyboard hits, -- is not.

If you want it to stay standard, then stick with standard libraries. Like Walt said, use "getchar()". Use any functions in the <stdio.h> and <stdlib.h> libraries. They will all be portable across all systems.


.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.