SOURCE FILE: getParams.pseudo
Pseudo-Code
/*
The job of this function is just to put some values in
some variables. The caller of the program furnishes
arguments which are bound to the formal parameters below:
filename, rows, and columns. The function obtains values
by questioning the user.
*/
/* ************************************************************ */
/* getParams */
/* ************************************************************ */
void getParams (string& filename, int& rows, int& columns)
{
/* Print prompt for file name */
/* read reply into parameter: filename */
/* Print prompt for number of tiles across */
/* read reply into parameter: columns */
/* Print prompt for number of tiles down */
/* read reply into parameter: rows */
}
Notes on C++ syntax:
* statements that write to the screen start like this:
cout <<
Example: cout << "Please enter your age ---> " ;
* statments that read from the keyboard start like this:
cin >>
Example: cin >> the_users_age ;
* This function has reference parameters (indicated by use
of ampersands (&). This is a requirement. Why?
Example Program:
#include <fstream>
#include <iostream>
#include <string>
#include <assert.h>
using namespace std;
/* ************************************************************ */
/* MAIN PROGRAM */
/* ************************************************************ */
int main ()
{
/* PROTOTYPES */
void getStringByRef (string & refStr) ;
void getStringByVal (string valStr) ;
/* VARIABLES */
string rStr = "INITIAL_REF",
vStr = "INITIAL_VAL";
getStringByRef (rStr) ;
cout << "in main, rStr is: " << rStr << endl << endl ;
getStringByVal (vStr) ;
cout << "in main, vStr is: " << vStr << endl << endl ;
return 0 ;
}
/* ************************************************************ */
/* getStringByRef */
/* ************************************************************ */
void getStringByRef (string & refStr)
{
cout << "Please type a string for 'refStr': " ;
cin >> refStr ;
cout << endl << "in getStringByRef, refStr is: "
<< refStr << endl;
}
/* ************************************************************ */
/* getStringByVal */
/* ************************************************************ */
void getStringByVal (string valStr)
{
cout << "Please type a string for 'valStr': " ;
cin >> valStr ;
cout << endl << "in getStringByVal, valStr is: "
<< valStr << endl;
}
/* ************************************************************ */
/* ************************************************************ */
/* ************************************************************ */