c++ and the unix environment

There is a mechanical aspect in the construction of a program that, in the
beginning, can be tedious and frustrating in its demand for precision.


using puTTY to logon to cisprod.clarion.edu
Use the putty telnet program running on Windows, to access cisprod.clarion.edu, a Sun machine running Unix. puTTY allows you to connect over the internet. logon to cisprod.clarion.edu use the pico editor to create C++ programs following the logic of your algorithm compile the program execute the program to solve the problem Download puTTy Click on FIRST exe (putty.exe) [note:windows only] Host name is "cisprod.clarion.edu" Save the file. It's ready to run! (double click file to run)
do it... enter command: ls
You are now using the Unix operating system... In the LAB Note: putty.exe is located on the C drive: (C:/) which can be accessed via "My Computer" (windows/E)

unix operating system
Unix Reference Links
Use what Unix command to list your files? Use what Unix command to list your files with details? Use what Unix command to change into your class account? puTTY on Intel PC connected to jupiter.clarion.edu, a Sun running Unix Unix bash shell • quota -v • ls [–la] [–lu] [-R] • cd [tab command completion] • mv [tab command completion] • cp [tab command completion] • rm [tab command completion] • CC [tab command completion] • mkdir • rmdir • ps • alias • who • man
• '&' running processes in the background / fg/ bg 'program1 &' runs in the background 'ctrl-z' stops program (but can be resumed - NOT killed) 'bg' resumes in the background 'fg' brings program into the foreground 'jobs' shows all jobs 'ps' shows processes • '|' pipes 'cat x.out | wc' puts the output of cat into the wc command 57 57 556 • '>' output redirection 'ls > x.out' puts the output of the ls command into a file, x.out • '>>' output redirection and append 'ls > x.out' appends the output of the ls command onto a file, x.out • '<' input redirection 'a.out < x.in' where x.in is a file that has the input for the program

editors: pico, emacs and vi

pico

we can easily create a program file (hello.cpp) with pico ( more about pico)

emacs

about emacs         emacs tutor
emacs is a powerful text editor.
This table is from wikipedia
Command Keystroke(s) Description
forward-char C-f Move forward one character (right).
backward-char C-b Move backward one character (left).
previous-line C-p Move to previous line (up).
next-line C-n Move to next line (down).
forward-word M-f Move forward one word.
backward-word M-b Move backward one word.
beginning-of-line C-a Move to beginning of line.
end-of-line C-e Move to end of line.
isearch-forward C-s Start incremental search forward.
isearch-backward C-r Start incremental search backward.
undo C-/ Undo last change, and prior changes if pressed repeatedly.
keyboard-quit C-g Abort the current command.
fill-paragraph M-q Wrap text in ("fill") a paragraph.
find-file C-x C-f Visit a file (you specify the name) in its own editor buffer.
save-buffer C-x C-s Save the current editor buffer in its visited file.
write-file C-x C-w Save the current editor buffer as a file with the name you specify.
save-buffers-kill-emacs C-x C-c Offer to save changes, then exit Emacs.
set-marker C-[space]/C-@ Set a marker from where you want to cut or copy.
cut C-w Cut all text between the marker and the cursor.
copy M-w Copy all text between the marker and the cursor.
paste C-y Paste text from the emacs clipboard
paste special C-x C-r Paste special text from the emacs clipboard (win32 only)
kill-buffer C-x k Kill a buffer by its name, or the current one if no name specified

vi and vim

Why vi? ( vi tutor) Despite its age, vi is still an important tool today. This is demonstrated by the fact that every unix/linux distribution released over the last twenty years is likely to have a copy installed by default. Since the original release of vi, many derivatives have been written (such as vim, vile and elvis), with usability and functionality added along the way. Because of this, vi is probably one of the most evolved and stable text editors in the world.
Many of the more recent vi clones are also intelligent enough to know about the type of document you are editing, and will help you out by automatically indenting your text (in the case of HTML or C, for example) or by highlighting the syntax to make your work much clearer. In the great Unix tradition, features that bug you or help you can be turned on and off at your preference, and spending a few minutes customising vi to your liking can save you hours of work in the long run. About the vi editor

code demo
   //////////////////////////////////
   //
   // Author : Wyatt Date : 1/1/2000
   // Purpose: To ask a user's name and to say hello
   // Design: Ask Name
   //         Store name
   //         greet user using stored name
   //
   // File: Hello.cpp
   /////////////////////////////////
   #include <iostream>
   using namespace std;

   int main ( )
   {
     // Local Data
     string firstName;   //input variable

     // Get name from user and store
     cout << "Enter your first name and press return: ";
     cin  >> firstName;

     // Display message and name
     cout << "Hi " << firstName << '.' << endl;
     cout << "We hope you enjoy studying C++ !\n";

     return 0;
   }