LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 11-06-2007, 08:12 AM   #1
Mohammed Akram
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Rep: Reputation: 0
Thumbs down 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.
 
Old 11-06-2007, 08:21 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980
please do not demand urgent help from a voluntary forum.
 
Old 11-06-2007, 08:32 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 64
Quote:
Originally Posted by acid_kewpie View Post
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 07:18 PM.
 
Old 11-06-2007, 09:33 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
And please provide the exact error. Futher there is a dedicated programming section at LQ, where your question might have fit better.
 
Old 11-08-2007, 10:52 AM   #5
Mohammed Akram
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 11-08-2007, 12:29 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980
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
 
Old 11-09-2007, 01:01 AM   #7
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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
 
Old 11-10-2007, 08:39 PM   #8
Mohammed Akram
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 11-11-2007, 06:38 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980
i think you need to start looking at documentation a little more... http://www.hmug.org/man/3/getch.php
 
Old 11-11-2007, 10:07 AM   #10
reverse
Member
 
Registered: Apr 2007
Distribution: Gentoo
Posts: 337

Rep: Reputation: 30
Erh.. in the interest of science.. what college are you in?
 
Old 11-12-2007, 11:52 AM   #11
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 252Reputation: 252Reputation: 252
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.
 
Old 11-13-2007, 07:26 AM   #12
Mohammed Akram
LQ Newbie
 
Registered: Nov 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Smile Allana college Pune

I am from Allana college pune.
May i know something about u...... ?
 
Old 11-13-2007, 11:55 AM   #13
wet
Member
 
Registered: Jul 2007
Distribution: Slackware 12, Fedora 8, Gentoo. (NO MORE MANDRIVA, GO AWAY EVIL THING)
Posts: 37

Rep: Reputation: 15
if you have a problem with some function, just type
Code:
man function
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 11:57 AM.
 
Old 11-20-2007, 03:33 PM   #14
geek_man
Member
 
Registered: Nov 2007
Distribution: Fedora 7, Fedora 9, Solaris 10, Mac OS X, RHEL5
Posts: 71

Rep: Reputation: 15
Quote:
Originally Posted by Mohammed Akram View Post
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.
 
  


Reply

Tags
fedora


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Compiling C Programs moserbear Linux - Newbie 7 09-20-2007 08:39 PM
Compiling C programs in Fedora Core 2 dreamydinesh Linux - Software 4 10-03-2005 02:51 AM
Compiling C++ programs rchillal Linux - Newbie 13 02-08-2005 06:27 AM
compiling programs disorderly Linux - Newbie 2 10-17-2003 01:48 PM
Compiling Programs Jabber63 Linux - Software 3 08-06-2003 03:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 04:44 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration