LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-30-2007, 03:35 AM   #1
amit_linux
LQ Newbie
 
Registered: May 2007
Posts: 16

Rep: Reputation: 0
Red face i cant run c program in linux anyone can help me?


hello to all...
i m new to linux and i m trying to run c program in c so problem is i cant include header file #include<conio.h> and its related function.....

pls help me out..
 
Old 05-30-2007, 04:32 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Hello lonely,

first of all the description of your problem is not very good so its quite hard to give you any pointers. Also please use some punctuations. Makes it easier to read.

My guess is you are trying to compile c code?

if the compiler can't find the included libraries i guess they are not installed or are in the wrong directory. Try to find the include file with

find / -iname "conio.h"

It should give you the full path to the file. If not, it's not installed.
Else copy it to the directory where you are compiling and change the line

#include <conio.h>

to

#include "conio.h"

This tells the compiler to look in the working directory and not in the include pathes.

If you need any further help after describing your problem a bit more I'm glad to help you out.

Regards zhjim
 
Old 05-30-2007, 04:57 AM   #3
amit_linux
LQ Newbie
 
Registered: May 2007
Posts: 16

Original Poster
Rep: Reputation: 0
Unhappy

[trainee@localhost progc]$ find /iname "conio.h"
find: /iname: No such file or directory
find: conio.h: No such file or directory
 
Old 05-30-2007, 04:58 AM   #4
amit_linux
LQ Newbie
 
Registered: May 2007
Posts: 16

Original Poster
Rep: Reputation: 0
above is error
 
Old 05-30-2007, 05:03 AM   #5
amit_linux
LQ Newbie
 
Registered: May 2007
Posts: 16

Original Poster
Rep: Reputation: 0
this is my program

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

int main(void)
{
clrscr();
char str[20];
printf("enter your string");
gets(str);
printf("entered string is %s",str);
return 0;
}
 
Old 05-30-2007, 05:43 AM   #6
Phil-B
LQ Newbie
 
Registered: May 2007
Location: UK
Distribution: Redhat variants
Posts: 10

Rep: Reputation: 0
conio.h is declares functions for MS-DOS I think. Not sure if you will find that on any Linux distribution.

I guess you need it for clrscr() - try replacing that with:

Code:
system("clear");
What happens if I type in a string that's 100 characters long?

Last edited by Phil-B; 05-30-2007 at 05:49 AM.
 
Old 05-30-2007, 06:11 AM   #7
amit_linux
LQ Newbie
 
Registered: May 2007
Posts: 16

Original Poster
Rep: Reputation: 0
thanks....
 
Old 05-30-2007, 10:10 AM   #8
UhhMaybe
Member
 
Registered: Jul 2004
Location: Salt Lake City, Utah
Distribution: Absolute 12.0 Studio 64 1.3.0
Posts: 470

Rep: Reputation: 30
Cool

Linux Distro's do include software compatibility with M$-DOS programs and terminal windows. They are not in every Distro, YOU will need to hunt around; or better yet, install the software to run the programs correctly.
 
Old 05-30-2007, 01:17 PM   #9
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 208

Rep: Reputation: 35
Quote:
Originally Posted by amit_linux
this is my program

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

int main(void)
{
clrscr();
char str[20];
printf("enter your string");
gets(str);
printf("entered string is %s",str);
return 0;
}
If i am not mistaken the function 'gets' is depreciated and shouldn't be used. Try using scanf.

Last edited by 0.o; 05-30-2007 at 01:19 PM.
 
Old 05-31-2007, 12:00 AM   #10
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Not sure if it's depreciated, but it's a security risk (buffer overflow) as a user can enter more characters than the size of the buffer (in the above example it's 19 plus a terminating NULL).

I think that scanf suffers from the same problem (correct me if I'm wrong).
I always use fgets.

PS there is a dedicated programming forum at LQ.

Last edited by Wim Sturkenboom; 05-31-2007 at 12:02 AM.
 
Old 05-31-2007, 07:23 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
iirc, although you may be able to find conio.h in an MS-DOS virtual env, it's not supported under native Linux (Unix doesn't assume the keybd in the same way) ... I could be wrong ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
QUICKEN-like program to run on LINUX dinchl Linux - Software 4 02-11-2007 01:40 PM
I need to run a linux program on windows 000jits Linux - General 2 08-16-2004 03:07 AM
How to run pascal program in Linux? zWaR Programming 5 02-04-2004 02:52 AM
bmp2html- how to run program in linux disorderly Linux - Newbie 3 11-21-2003 12:42 AM
Run WINNT Program in Linux ckamheng Linux - Software 7 05-07-2003 09:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration