See if your Mac has the application
Xcode.
Go to the Finder,
pull down the
File
menu, select
Find
,
and search for
Xcode.app
.
Its icon is a hammer on a blue background.
If you don’t find Xcode,
download it from
here.
To install the newest version of Xcode,
you might need the newest version of the Mac OS X operating system.
If you don’t feel like upgrading your operating system,
get an old version of Xcode from
connect.apple.com
.
Downloads → Developer Tools
and look for older versions of Xcode.
Xcode.app
.
File
→
New
→
New Project…
Mac OS X
,
select
Application
.
Command Line Tool
.
Next
Product Name: Prog
Company Identifier: edu.nyu.scps
Type C++
Next
Desktop
and
press Create
.
main.cpp
to edit it.
(If you don’t see main.cpp
,
View → Navigators → Show Project Navigator
)
// insert code here…
.
std::cout
to
cout
,
you must insert
using namespace std;
return 0;
return
EXIT_SUCCESS;
#include <cstdlib> //for EXIT_SUCCESS
main.cpp
file.
File
→
Save
Run
button in the upper left.
View → Debug Area → Activate Console
View → Debug Area → Show Debug Area
Products
folder.
(If you don’t see the Products folder,
View → Navigators → Show Project Navigator
)
Prog
,
and select
Show in Finder
.
Control-click on
Prog
in the Finder and select
Prog
.
Launch the
Terminal
application and type the following commands in it.
The argument of the first
cd
should be the outrageously long directory name you just got from Get Info.
cd /Users/nyuuser/Library/Developer/Xcode/DerivedData/Prog-ccyafydmrhjgzqetmkytdgfgfdek/Build/Products/Debug pwd ls -l prog
./prog (direct the standard output to the terminal window) echo $? (see prog’s exit status)
./prog > prog.out (direct the standard output (cout) to the file prog.out) ls -l prog.out
./prog 2> prog.err (direct the standard error output (cerr) to the file prog.err) ls -l prog.out
./prog > prog.out 2> prog.err ./prog > prog.combined 2>&1
term
.
main.cpp
to edit it.
Overwrite the entire file with the
main.C
that draws
XX
.
File
→
Save
term
folder.
Do not rename them.
Project
→
Add to Project…
term.h
and
term.c
to the project.
You’ll have to press
Add
twice for each file.
term.c
to edit it.
Uncomment the
#define UNIX
.
Change each expression in column 1 to the corresponding expression
in column 2.
stdscr->_begx |
getbegx(stdscr) |
|
stdscr->_begy |
getbegy(stdscr) |
|
stdscr->_maxx |
getmaxx(stdscr) |
|
stdscr->_maxy |
getmaxy(stdscr) |
size_t
is another name for
unsigned long
on this platform.
In
term_puts
,
change
length %u
to
length %lu
and change
subscript %u
to
subscript %lu
.
File
→
Save
libcurses.dylib
to your project.
Project
→
Edit Active Target "proj"
→
General
→
Linked Libraries
libcurses.dylib
.
Press
Add
.
Build and Run
.
Terminal
application
as in the above ¶ 7, not in the
Xcode
application.
cd /Users/yourname/Desktop/term/build/Debug pwd ls -l term
./term Please type printable characters ending with a q. Hello, how are you? q echo $? 0