Assignment 1 - accessing your account and compiling a program as proof.
You should be able to complete this during our lab visit. But extra time is
provided if additional help needed.
Due 26 Aug 2016
Meet in the CSL lab, PM 56, for our August 31st class.
Log into one of the lab machines.
Make sure Xming Server is running. There should be an X in the
System Tray - lower right hand of the Windows Desktop.
If Xming is not running, click on the Windows flag (lower left)
Type Xming # the Xming Desktop app should be listed.
Click on it. # the Xing icon should appear in the tray in the lower right.
Log into hopper or turing and activate your account, if you have not
already done so.
Login Instructions
Once logged in, run the command
at the prompt.
Remember to press [enter] after entering a command.
geany is a IDE, similar to DevC++ but for the Linux platform
and will pop up in a separate window on your Windows desktop
Enter the following code :
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;
int main( int argc, char * argv[] )
{
int count = 1;
cout << "Welcome " << getenv("USER") << "\n\n";
cout << "Sample C++ program\n";
// show all command line arguments
for( int i=0; i < argc; i++ )
{
cout << "argv[" << i << "] = " << argv[i] << endl;
}
// if no argument was given, prompt the user
if( argc == 1)
{
cout << "Enter number to repeat: ";
cin >> count;
}
else
{
count = atoi( argv[1]);
}
// show line a few times
for( int i=0; i < count; i++ )
{
cout << "C++ is fun !\n";
}
return 0;
}
Save program in your home directory. assn1.cpp is a good name to use.
Once done entering the code, click [Compile] on the tool bar.
Correct any errors and repeat [Compile]
When no errors reported, save again.
Click [Build]. This will create an executable with the same name.
Click [Execute] to run. A new window will pop up on your Windows Desktop
with the output.
Hit [enter] when satisfied.
Close geany
Back at the Linux terminal window
- Execute your program.
./assn1
Note the ./ and that the .cpp is not specified when running.
- If output looks correct, proceed to final assignment steps.
Submitting assignment.
Run the command :
script
Note : script records all terminal I/O in a file called typescript
Run the command :
Run the command :
Run your program assn1 with a couple of arguments. These can be any word or
number. Remember to specify ./ before the program.
Press <Ctrl>D
You will exit the script command. There will be a file called
typescript in your home directory.
Mail this to me. Use :
mutt berezin < typescript