Member Avatar for Brian Perrigan
Brian Perrigan

Can someone help me develop the pseudo code for this so I can try and code it out? I'm getting confused about how to develop this simple program:

Problem: Develop a Null Cipher Coder using Nested Loops and Command Line Arguments:

Encoded .cry files can be found here: I downloaded a few and put them in a zip file just in case anyone wants to take a look.
http://www.mediafire.com/?pp98g53z9g5dj2y

Tools:

cin.get();
cout.put() ;
while (! cin.eof()) {

Code to get you started:

int c ;
c = cin.get() ; // read and lose bad char
do
{
	(something) 
	cout.put(c)   ; // print good char
	c = cin.get() ; // read and lose bad char
} while ( ! cin.eof()) ;

add one or more cin.get()
statements prior to the one which you print.
They will filter out the null bytes, then
the good character will be read and printed,
and the process will be repeated for the length
of the file.

do not do this manually. use a nested for loop.
Write ONE general purpose form of the program that can process any number
of nulls. That is to say, can decode any of the document?.cry files?

To do this, you would make a command line switch control the
program. Command line switches are stored in the argv[] array.
Look at the definition of main:

int main (int argc, char *argv[])

So, you would define a variable

int nulls ;

to tell the program HOW MANY c = cin.get() ; statements to
run in a given program execution.

You would run the program: a.out 4 < document4.cry

To get the 4 (or whichever number) into the program, you
would use:

nulls = atoi(argv[1]) ;

Here's what I've got so far:

PSEUDO CODE:

DEFINE C AS INTEGER VARIABLE
READ IN CHARACTER
START LOOP NESTED LOOP WITH DO
PUT FOR LOOP HERE
PRINT GOOD CHAR
GET ANOTHER CHARACTER -- START LOOP AGAIN
WHILE cin.eof()

I'm I heading the right direction?