how to run c Program????

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
Post Reply
hanybee
Havaldaar
Posts: 142
Joined: Wed Aug 04, 2004 1:53 pm
Location: faisalabad
Contact:

how to run c Program????

Post by hanybee »

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
Anjum Butt
Company Havaldaar Major
Posts: 165
Joined: Mon Jun 09, 2003 9:02 am
Location: Karachi

Post by Anjum Butt »

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
More will follow :)

Anjum Butt
Registered Linux User #314299
Qadri-409
Battalion Havaldaar Major
Posts: 286
Joined: Sun May 09, 2004 4:16 pm
Location: Peshawar
Contact:

Re: how to run c Program????

Post by Qadri-409 »

hanybee 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
http://vergil.chemistry.gatech.edu/reso ... intro.html

takecare
M Shahzad Qadri
MAJID
Naik
Posts: 90
Joined: Thu Oct 16, 2003 10:23 pm
Contact:

Post by MAJID »

Hello ,

Your code look like this
[root@imrant root]# cat hello.c
#include <stdio.h>
main (void)
{
printf("Hello on Linux");
}
Compile it
[root@imrant root]# gcc hello.c
Make sure you have 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
Execute a.out
[root@imrant root]# ./a.out
Hello on Linux[root@imrant root]#
01101101 01100001 01101010 01101001 01100100
Post Reply