Re: [suse-programming-e] C Programming in Linux
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tue, 16 Dec 2003 15:32:10 EST KPP52@aol.com wrote:
I have Personal 9.0 I wrote the basic C program first.c then I did: gcc -o first first.c then I tried to run it by typing: first and it gives me a message: bash first no such command. so I tried: gcc first.c there was an a.out file in the directory then I typed: a.out and it gives me the same error message. Is there something I'm missing with the C compiler here? I'm new to SuSE and new to linux in general. I have done some C programming in Unix and this is confusing me tremendously. Any help would be greatly appreciated.
Let me add some clarifications to some of the postings on this. I think
that Keo gave the correct answer (This is what I posted to the SuSE
English list):
gcc -o first first.c
This creates the file, first, with the correct executable permissions.
gcc first.c
This creates a.out with the correct executable permissions.
As Gary mentioned, by default SuSE (and nearly every other Linux and
Unix system) does not include the current directory in your PATH
environment variable for security reasons. For this reason, you must use
either absolute or relative path to execute files that are not in your
PATH. For this reason, to execute anything in your current directory,
you must use the relative path (eg. ./<name of file> ) or the full path
(eg. /home/yourusername/<path to current directory>/<filename>).
So to execute first:
./first
or to execute a.out:
./a,out
- - --
Jerry Feldman
On Tue, 16 Dec 2003, Jerry Feldman wrote:
So to execute first: ../first
or to execute a.out: ../a,out
Should be ./first or ./a.out (only one dot before the slash) if first and a.out are in the current directory. (Two dots, as in ../second, takes you to the directory immediately above.) Do ls . (for the current directory) and ls .. (for the one above) to see this.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You are absolutely correct, that was a typo.
On Tue, 16 Dec 2003 18:39:33 -0800 (PST)
Michael Marking
On Tue, 16 Dec 2003, Jerry Feldman wrote:
So to execute first: ../first
or to execute a.out: ../a,out
Should be
./first
or
./a.out
(only one dot before the slash) if first and a.out are in the current directory.
(Two dots, as in ../second, takes you to the directory immediately above.)
- --
Jerry Feldman
participants (2)
-
Jerry Feldman
-
Michael Marking