Fedora This forum is for the discussion of the Fedora Project. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
11-06-2007, 07:12 AM
|
#1
|
LQ Newbie
Registered: Nov 2007
Posts: 6
Rep:
|
Compiling C Programs in Fedora
Hi,
this is Akram please help me out....
i have instal fedora to do practicals of c program.
but i am not able to compile and execute.
but if execute the same on windows then it is workling fine.....
please give me the detaile of how to complie and execute it on Fedora
i had tryed by
gcc filename.c
it is giving an eror"This file or directory does not exist eventhough i am on the same directry.
|
|
|
11-06-2007, 07:21 AM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
please do not demand urgent help from a voluntary forum.
|
|
|
11-06-2007, 07:32 AM
|
#3
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
Quote:
Originally Posted by acid_kewpie
please do not demand urgent help from a voluntary forum.
|
Unless there is money attached? I'll respond urgently for cold hard cash
Seriously though, can you execute these commands from the shell (in the directory where your file is) and paste the results. Please do not quote them in part - paste the whole output:
Code:
ls -l filename.c
which gcc
gcc --version
Finally, if it is not too long, please insert the contents of the filename.c file.
Please enclose all these things in [code] tags to aid readability.
Last edited by matthewg42; 12-15-2007 at 06:18 PM.
|
|
|
11-06-2007, 08:33 AM
|
#4
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,797
|
And please provide the exact error. Futher there is a dedicated programming section at LQ, where your question might have fit better.
|
|
|
11-08-2007, 09:52 AM
|
#5
|
LQ Newbie
Registered: Nov 2007
Posts: 6
Original Poster
Rep:
|
Hi, chris
Thanks for the help.
i am the first in my college to execute any c program on Linux but The problem is i am not able to use the function of other library such as <conio.h>
and not even the scanf();
it is saying that no detail is given for it.
please help me.
|
|
|
11-08-2007, 11:29 AM
|
#6
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
conio.h does not exist under linux in any widely acknowledged state. you need to use suitable equivalents, e.g. the ncurses library for some of that functionality
|
|
|
11-09-2007, 12:01 AM
|
#7
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,797
|
For scanf, you have to include stdio.h
Code:
#include <stdio.h>
int main (int argc, char * argv[])
{
int i;
printf("Enter a number: ");
scanf("%d",&i);
printf("You entered: %d\n",i);
return 0;
}
Compile with gcc -Wall myfile.c -o myfile and run with ./myfile.
Code:
wim@desktop1:~$ ./myfile
Enter a number: 55
You entered: 55
wim@desktop1:~$
If the compiler complains about stdio.h, your configuration is broken in some way.
PS
There is a conio for linux, but it seems to be a wrapper around ncurses. Search for linux conio
|
|
|
11-10-2007, 07:39 PM
|
#8
|
LQ Newbie
Registered: Nov 2007
Posts: 6
Original Poster
Rep:
|
Thanks for the help but i have one more problem.
i am not able to use the simple code like
getch();
in my program.
same error messege is comming no defination is given for the getch();
what must be done to avoid the same.
|
|
|
11-11-2007, 05:38 AM
|
#9
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
i think you need to start looking at documentation a little more... http://www.hmug.org/man/3/getch.php
|
|
|
11-11-2007, 09:07 AM
|
#10
|
Member
Registered: Apr 2007
Distribution: Gentoo
Posts: 337
Rep:
|
Erh.. in the interest of science.. what college are you in?
|
|
|
11-12-2007, 10:52 AM
|
#11
|
LQ Guru
Registered: Jan 2001
Posts: 24,149
|
Moved to Fedora forum where this is more suitable and changed the title to something more suitable as well, instead of "Urgent" which doesn't describe your post or question whatsoever.
|
|
|
11-13-2007, 06:26 AM
|
#12
|
LQ Newbie
Registered: Nov 2007
Posts: 6
Original Poster
Rep:
|
Allana college Pune
I am from Allana college pune.
May i know something about u...... ?
|
|
|
11-13-2007, 10:55 AM
|
#13
|
Member
Registered: Jul 2007
Distribution: Slackware 12, Fedora 8, Gentoo. (NO MORE MANDRIVA, GO AWAY EVIL THING)
Posts: 37
Rep:
|
if you have a problem with some function, just type
should provide you with alot of info about the function - which #includes you need, arguments, return values, behavior etc
(and dont tell me man pages are ugly! )
Last edited by wet; 11-13-2007 at 10:57 AM.
|
|
|
11-20-2007, 02:33 PM
|
#14
|
Member
Registered: Nov 2007
Distribution: Fedora 7, Fedora 9, Solaris 10, Mac OS X, RHEL5
Posts: 71
Rep:
|
Quote:
Originally Posted by Mohammed Akram
i am not able to use the simple code like
getch();
in my program.
same error messege is comming no defination is given for the getch();
what must be done to avoid the same.
|
Hi!
This is because getch() is defined in conio.h, which is not an ANSI C library.
If you include #include <stdio.h> you can use getchar()
There are some differences between getch() and getchar() but I think this can help you.
|
|
|
All times are GMT -5. The time now is 03:42 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|