Problems with terminal SSH compiling.

Joined
Jan 15, 2009
Messages
2
Reaction score
0
Points
1
I have a CS 161 assignment due tomorrow and I am using terminal to log into SSH on my Mac IBook G4. I have written the program but when getting to the end and typing control O to write the program, it is not letting me exit once there. I tried typing g++ prog1.cpp to compile and it does nothing. The program itself is very simple and I have looked it over for mistakes and can find none. I am using nano. I tried using pico but I received an error message. Can anyone help with this? Below is what I have typed for my program. Thanks!

//Header file
#include <iostream>

using namespace std;

//Named constants
const int HALFDOLLAR = 50;
const int QUARTER = 25;
const int DIME = 10;
const int NICKEL = 5;


int main()
{
//Declare variable
int change;

//Statements: Step 1- Step 12
cout << "Enter change in cents: "; // Step 1
cin >> change; // Step 2
cout << endl;

cout << "The change you entered is " << change
<< endl; // Step 3

cout << "The number of half-dollars to be returned "
<< " is " << change / HALFDOLLAR
<< endl; // Step 4

change = change % HALFDOLLAR; // Step 5

cout << "The number of quarters to be returned is "
<< change / QUARTER << endl; // Step 6

change = change % QUARTER; // Step 7

cout << "The number of dimes to be returned is "
<< change / DIME << endl; // Step 8

change = change % DIME; // Step 9

cout << "The number of nickels to be returned is "
<< change / NICKEL << endl; // Step 10

change = change % NICKEL; // Step 11

cout << "The number of pennies to be returned is "
<< change << endl; // Step 12

0;
}
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Is nano not letting you exit? After doing the control-o are you typing control-x?
Or are you having problems with the compile in the shell?
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
nano is a pico clone (but it is installed by default in os x), pico's only going to be installed (usually) if you've installed pine as a mail reader. While I don't use either much (I prefer vi), when I do I use ctrl-x to exit and save it when prompted to.
 
OP
M
Joined
Jan 15, 2009
Messages
2
Reaction score
0
Points
1
Yes, after pushing control-x, it will not let me exit. As well, When prompting it to compile, by typing: g++ prog1.cpp it will not compile.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
is there an error that you get when you try to exit and compile?
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
When you do a control-x do you get a shell prompt? Or are you still in nano?
Dumb question, you DO have xcode installed on your ibook right?
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
I would use the vi editor, since it comes with every favor of Unix operating system.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
I would use the vi editor, since it comes with every favor of Unix operating system.
I agree, but then we run into having a very non-user friendly text editor.. and I use vi daily and love it.. but people who don't know it using it (especially in /etc) scares the bejesus outa me ;)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top