conio.h: No such file or directory

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
Morning
Experienced poster
Posts: 134
Joined: Fri Aug 01, 2003 2:18 pm
Location: Shanghai China

conio.h: No such file or directory

Post by Morning »

I wanna use the getch() function,but the judge system said that "01767330_24.c:4:19: conio.h: No such file or directory".
Please tell me how to solve the problem if u know.Thank u!
Viktoras Jucikas
New poster
Posts: 22
Joined: Sun Oct 20, 2002 6:41 pm
Location: Lithuania
Contact:

Post by Viktoras Jucikas »

getch() is Borland compiler specific function (non ISO). conio.h header is also present only in Borland products, thus judge system (which is GNU GCC suite) does not have them. Try using scanf()/printf() family or iostreams instead.
Morning
Experienced poster
Posts: 134
Joined: Fri Aug 01, 2003 2:18 pm
Location: Shanghai China

Post by Morning »

Thank U Very Much!!!
Ivor
Experienced poster
Posts: 150
Joined: Wed Dec 26, 2001 2:00 am
Location: Tallinn, Estonia

Post by Ivor »

you can user getchar() or fgetc()

Ivor
There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.
Morning
Experienced poster
Posts: 134
Joined: Fri Aug 01, 2003 2:18 pm
Location: Shanghai China

Post by Morning »

Thank u!Ivor! :D
"Learning without thought is useless;thought without learning is dangerous."
"Hold what you really know and tell what you do not know -this will lead to knowledge."-Confucius
Morning
Experienced poster
Posts: 134
Joined: Fri Aug 01, 2003 2:18 pm
Location: Shanghai China

Post by Morning »

I wonder if there's a function that exactly like getch()?
fuction such as cin.get(),getchar() will wait for "enter".Is there a function that will reflect immediately when i input a simple character?
"Learning without thought is useless;thought without learning is dangerous."
"Hold what you really know and tell what you do not know -this will lead to knowledge."-Confucius
Ivor
Experienced poster
Posts: 150
Joined: Wed Dec 26, 2001 2:00 am
Location: Tallinn, Estonia

Post by Ivor »

it does wait for a newline in case you are inputting from console. In case your standard input is redirected from a file then it will get you next character without any problems. <conio> functions are especially done for console io, to add functionality. getchar waits for enter because so you can change entered data. But with redirected standard input it will simply use line buffering. It will internally buffer till a newline. And will give you requested character without any delay.

Ivor

P.S. When I solve problems I always use redirected input. A lot more silmpler.
There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.
Post Reply

Return to “C++”