how to run c Program????

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.

how to run c Program????

Postby hanybee » Sat Apr 30, 2005 12:00 am

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
hanybee
Havaldaar
 
Posts: 142
Joined: Wed Aug 04, 2004 1:53 pm
WLM: mianhassan786@hotmail.com
Yahoo Messenger: mianhassan786@yahoo.com
Location: faisalabad

Postby Anjum Butt » Sat Apr 30, 2005 1:35 am

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

Re: how to run c Program????

Postby Qadri-409 » Mon May 02, 2005 12:14 am

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
Qadri-409
Battalion Havaldaar Major
 
Posts: 286
Joined: Sun May 09, 2004 4:16 pm
WLM: qadri409
Yahoo Messenger: shahzadqadri409
Location: Peshawar

Postby MAJID » Sun May 22, 2005 1:48 am

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
MAJID
Naik
 
Posts: 90
Joined: Thu Oct 16, 2003 10:23 pm
ICQ: 269695850


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron