conio在linux上

来源:互联网 发布:自动抢微信红包软件 编辑:程序博客网 时间:2024/04/29 04:06

  conio.h是tc里面的一个头文件.之前尽管有cpp文件,在windows下dev中也没有弄成功,linux下自然也是如此.

参考了以下文章,对于conio问题有以下认识:

 

1.borland公司创造,工作于dos平台,已经很老了.

2.即使linux上有conio,也无法在linux平台运行.因为conio的实现是调用bios,而linux是没有bios的.

3.stdio.h and stdlib.h文件是标准的文件,里面完全存在替代conio功能的函数.



====================================================================

http://www.coderanch.com/t/110082/Linux-UNIX/Unable-bind-header-file-conio

 

conio.h is a non-standard header. It works mostly on DOS platforms.
If you want to include conio.h to clear the screen (i.e use clrscr() ) then you can instead use `system("clear");`.


<conio.h> is not part of the standard library. Any functions that are
prototype in that header are also non-standard.

Try to comment off the #include <conio.h> line. If your only offending line
is a single `getch();` just before main() returns, remove that line too.
And you`re done.

Other than that, got to look at the actual codes to see what needs to be
done.


Unable to bind the header file :conio.h
girish rateshwar
Ranch Hand

Joined: Mar 04, 2001
Messages: 97

   
[Post New]posted 09/09/2003 23:34
Quote [Up]
Dear all,
I have a c++ program (password.cc) which contains a header file conio.h.
Now when i have copied this file on my linux machine and try to compile it : g++ password.cc
I get the following error:
conio.h No such file or directory.
To resolve this i tried to look for the header file and managed to get it from my friend and copied it to /usr/i386-glibc21-linux/include
But i keep gettin the same error!
Do i have the original conio.h or there is some otehr way of doin it.
Help Appreciated
Girish
Tim Holloway
Bartender

Joined: Jun 25, 2001
Messages: 6509

   
[Post New]posted 10/09/2003 00:50 private message
Quote [Up]
I think conio.h was an old (and I mean REALLY old) DOS file header for doing things that you'd use curses for in a Unix/Linux environment. It may have been a Borland-specific function.
So most likely you'll have to do some rewriting.
People think any child can program. Which is probably why so many programs behave like they were written by children.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Messages: 5093

   
[Post New]posted 10/09/2003 16:02 private message
Quote [Up]
conio.h is a C headerfile for doing con(sole) IO. It could well be OS specific of course, but I think I also saw it in MSVC (don't have it installed here so can't check).
check out stdio.h and stdlib.h instead which is pretty much platform independent and is there.
btw, the include files are in /usr/include at least on my machine.
You could always try putting conio.h with your .cc file and referencing it as a local include, but you'd likely get linker errors from missing libraries referenced from conio.h (DOS system calls) if you do so.
42
Tim Holloway
Bartender

Joined: Jun 25, 2001
Messages: 6509

   
[Post New]posted 11/09/2003 01:37 private message
Quote [Up]
Yup. I'm sitting at a machine with Visual Studio on it and conio.h is part of the MSVC app. Mostly it's got cheap replacements for string input/output via the console, but I think the main thing I used it for was the getch() and kbhit() functions.
I think all these calls go straight to the BIOS. Linux runs on machines where BIOS's don't exist (which is EVERYTHING except IBM-PC machines), so conio doesn't work there.
It's mostly a simple conversion except for cases where you're trying to read passwords without echoing and do unbuffered character-at-a-time I/O. In the Unix environment, you have to use stty to alter the default console operations.
People think any child can program. Which is probably why so many programs behave like they were written by children.
girish rateshwar
Ranch Hand


Joined: Mar 04, 2001
Messages: 97

   
[Post New]posted 12/09/2003 21:20
Quote [Up]
Dear Tim,
I know im asking for more, but thats what javaranch is good at
Well im developing an interface where im connecting to mysql and validating the username and password. I need to change the text 'abc' -->> '***' on linux. Im developing this in c++.
Can u pls let me know if there is any code available with u?
Thanks!!!!!!
Girish
Tim Holloway
Bartender

Joined: Jun 25, 2001
Messages: 6509

   
[Post New]posted 13/09/2003 01:59 private message
Quote [Up]
I'm afraid I don't have anything I can dig out. This website looks like it may help though. I found it off Google:
http://puggy.symonds.net/~deep/stuff/tekmail/unixfun.php
By convention, Unix doesn't echo stars when you're entering a passwrod-like field. For one thing, even allowing casual viewers to see how many characters in the password is considered a possibly valuable clue.
People think any child can program. Which is probably why so many programs behave like they were written by children.

原创粉丝点击