?
Solved

To compile and execute a C++ file in UNIX

Posted on 1999-01-28
4
Medium Priority
?
176 Views
Last Modified: 2010-04-02
I compiled a c++ file in Unix as gcc filename.cc. It didn't give me any error. But when I type a.out next it is saying file not found or bad command. The same thing is happening when I try to compile and run a C file giving the command cc filename.c and a.out.

Kindly help me.
0
Comment
Question by:thenmozhia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 1185437
Try this:

/a.out

My guess is that you're logged in as root and the default PATH for root is NOT to include the current directory or ".".  By saying ./<program_name> you're telling the shell to run the a.out in the current working directory.

You can also compile with the -o option like this:

gcc filename.c -o filename

so the output will go to filename instead of to a.out.

0
 

Author Comment

by:thenmozhia
ID: 1185438
I found Jhance answer is correct. By mistake previously I rejected his anwer. Sorry for that.

Thankyou
0
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 1185439
OK, how about we try it again.....
0
 

Author Comment

by:thenmozhia
ID: 1185440
o.k. and Thankyou so much.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question