Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Enix18

macrumors newbie
Original poster
May 14, 2008
3
0
Here's a simple question: How do you open C++ mode in Terminal?
 
I thought you could type a certain command to start working in C++, just like you can for Python... (I'm pretty new to this, so I really have no idea)
 
No, you write all the code into a file and the call the compiler to turn that into object code. The major difference is that Python is interpreted (so can be used interactively like you are describing), C++ is compiled so cannot be used interactively.
 
You might have heard of the "C shell". When you use Terminal, you are running a Unix-style shell program. There are various shells in the world, with names like sh, bash, csh, and tcsh. bash is an extended version of sh and tcsh is an extended version of csh, and Mac OS X uses bash and tcsh but calls them sh and csh for backward compatibility reasons.

csh and tcsh are called C shells because they can execute scripts (executable text files) that use syntax similar to the C programming language. Perhaps that's what you heard about. You aren't in the real C or C++ programming langauge, however.

If you are already in Terminal, you can enter the tcsh C shell by typing
Code:
/bin/csh
This starts a shell with a shell. To get back out to the original shell, type
Code:
exit
Finally, if you want to, you can set your default Terminal shell to tcsh so launching Terminal will put you directly into a C shell.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.