hello friends
i m facing a small problem here
i m try to run a simple c program in linuv
when i try to complile by using commadn g++ first.c
it complie it and create a file a.out and when i try to run that file it give me message that Command not found tell me what i do for that
one think i guessing about it is that my path is not set from here
i m try to edit it in /etc/profile
also tell me what is the right way to set it
waiting for ur reply
hassan
how to run c Program????
-
- Company Havaldaar Major
- Posts: 165
- Joined: Mon Jun 09, 2003 9:02 am
- Location: Karachi
AoA,
first if its a .c program, you should compile it using
gcc -o first first.c
then execute it using
./first
PS,
its a bad practice to add every working path in /etc/profile or ~/.bash_profile
doing so will cause chaos within a stable working system
first if its a .c program, you should compile it using
gcc -o first first.c
then execute it using
./first
PS,
its a bad practice to add every working path in /etc/profile or ~/.bash_profile
doing so will cause chaos within a stable working system
More will follow
Anjum Butt
Registered Linux User #314299
Anjum Butt
Registered Linux User #314299
-
- Battalion Havaldaar Major
- Posts: 286
- Joined: Sun May 09, 2004 4:16 pm
- Location: Peshawar
- Contact:
Re: how to run c Program????
http://vergil.chemistry.gatech.edu/reso ... intro.htmlhanybee wrote:hello friends
i m facing a small problem here
i m try to run a simple c program in linuv
when i try to complile by using commadn g++ first.c
it complie it and create a file a.out and when i try to run that file it give me message that Command not found tell me what i do for that
one think i guessing about it is that my path is not set from here
i m try to edit it in /etc/profile
also tell me what is the right way to set it
waiting for ur reply
hassan
takecare
M Shahzad Qadri
Hello ,
Your code look like this
[root@imrant root]# cat hello.c
Your code look like this
[root@imrant root]# cat hello.c
Compile it#include <stdio.h>
main (void)
{
printf("Hello on Linux");
}
Make sure you have a.out[root@imrant root]# gcc hello.c
Execute a.out[root@imrant root]# ls
a a.out hello.c mbox
amsn_received cd install.log wget-log
anaconda-ks.cfg Desktop install.log.syslog
[root@imrant root]# ./a.out
Hello on Linux[root@imrant root]#
01101101 01100001 01101010 01101001 01100100