LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (https://www.linuxquestions.org/questions/fedora-35/)
-   -   Compiling C Programs in Fedora (https://www.linuxquestions.org/questions/fedora-35/compiling-c-programs-in-fedora-597494/)

Mohammed Akram 11-06-2007 07:12 AM

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.

acid_kewpie 11-06-2007 07:21 AM

please do not demand urgent help from a voluntary forum.

matthewg42 11-06-2007 07:32 AM

Quote:

Originally Posted by acid_kewpie (Post 2949899)
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.

Wim Sturkenboom 11-06-2007 08:33 AM

And please provide the exact error. Futher there is a dedicated programming section at LQ, where your question might have fit better.

Mohammed Akram 11-08-2007 09:52 AM

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.

acid_kewpie 11-08-2007 11:29 AM

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

Wim Sturkenboom 11-09-2007 12:01 AM

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

Mohammed Akram 11-10-2007 07:39 PM

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.

acid_kewpie 11-11-2007 05:38 AM

i think you need to start looking at documentation a little more... http://www.hmug.org/man/3/getch.php

reverse 11-11-2007 09:07 AM

Erh.. in the interest of science.. what college are you in?

trickykid 11-12-2007 10:52 AM

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.

Mohammed Akram 11-13-2007 06:26 AM

Allana college Pune
 
I am from Allana college pune.
May i know something about u...... ?

wet 11-13-2007 10:55 AM

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! ;))

geek_man 11-20-2007 02:33 PM

Quote:

Originally Posted by Mohammed Akram (Post 2954786)
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:26 AM.