 |
 |
C++ programming and terminal.app
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
I am about to start a C++ course and I would really appreciate some info on how to use the terminal.app to do some programming. I have installed ProjectBuilder but it seems complicated to use - all I need is to write simple programs for now.
I know you can use Textedit to write the program. Then use "c++" in terminal to compile it. But how do you run it?
Is it similar to Java where you can use "javac" to compile and "java" to run?
If I got any of this stuff wrong please tell me!
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
If you're doing it solely from the terminal...
Write a text file, call it something like "main.cpp"
I've never used c++, but I assume the command line syntax is identical to cc, do a "man c++" (which will probably head you to the dev. documentation) for options.
c++ -o program main.c
The -o will make a program named "program"; without the -o it'll be a.out (I believe).
Then type ./<program name> (e.g. ./a.out) to run the thing.
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
Thanks. I will try that as soon as I get home.
Incidentally, what I know comes from reading this forum. Should I be using "cc" and not "c++" to compile my code? It seems everybody is using it and nobody mentions "c++" at all.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Neuchâtel, Switzerland
Status:
Offline
|
|
Don't forget the :
chmod u+x <program name>
to have the permission to execute it !!!
|
|
--
Francis Olof Garnier
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
c++ should automatically write your permissions correctly.
cc is for ObjC and C, c++ is C++ (to my knowledge).
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
cc is generally for C, I think all c++ does is invokes cc with the right commands so that it compiles C++, i'm pretty sure you can compile C++ using cc with some flags... Unsure though.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Status:
Offline
|
|
Yay! I tried using c++ and it seems to work. The output is the same as in the book I am using. I will try cc and see if it makes a difference but not sure about those flags though.
Thank you! You've all been a big help to a real beginner!
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |