Ethan L. Schreiber

    Home    Research     Code    Reference    Links    Miscellaneous    Contact    cs31    rss feed    Resumé    

Office Hours

  • Tuesdays 2:30 - 4:30 in BH 4428
  • On other days or times, you can try to see if I am in BH 4684 or sent me an email at ethan@cs.ucla.edu.

Friday, November 21, 2008

The const reference I mentioned in class is located here
  • circle.cpp - Shows the use of a c++ struct.
  • geometry.hpp - Required for circle.cpp.
  • string.cpp - Shows the definition of a simple class. This is a simple version of the stl string class but is much simpler and is probably not perfect so please take it with a grain of salt. It's main purpose is to show you the basic usage of a class.
  • string.h - Required by string.cpp.

Note on fileMatrix.cpp (Monday, November 17, 2008)

Noemi pointed out to me that my implementation of fileMatrix.cpp failed when the input file has the same number of lines as the maximum number of rows in the 2-dimensional matrix. I have fixed the code. Try to look through the loop that fills in the matrix and see if you understand why it broke before.

Friday, November 14, 2008

Note on Project 3 (Tuesday, November 11, 2008)

First off, I stated incorrectly in class that the maximum width of a line in the cipher file is 200 characters. The correct width as specified in the project is 80 characters.

Secondly, people asked about how you could check that repeated letters in the crib correspond correctly to repeated letters in the cipher file. I have since thought about this and here is my general strategy:

As we discussed both in section and also in office hours with some people, one way to map characters in the cipher file to their correct character from the crib file is to use an array of length 26:

char key[26];

The 0th element in the array corresponds to 'a' in the cipher file, the 1st to 'b', the 2nd to 'c' etc. After we have found that the crib matches the cipher file somewhere, we can next start constructing this key. The way you would do this is by iterating through the cipher file from the start position of the match with the crib. For each character you see, you will set the corresponding spot in the key array. You can use our ascii arithmetic as follows:

char c; // this is a character from the cipher file.
key[tolower(c) - 'a'] = toupper(c);

So, if char c = 'd', the 2nd line would be effectively:

key[3] = 'D';

Now, while you are filling in this array, you can first check to make sure that the value has not been set already. If it was set, you should make sure you don't set it to a different value the second time. If the value is different, than you no longer have a match. Of course, this means that before you attempt to create your key array, you have to initialize all 26 slots to some special value.

I do not know that this is the best way to do it but it is a way to do it and in fact the way that I did it so I can verify it works. I hope this is somewhat helpful. Good luck and do please feel free to ask me if you have any questions.

Friday, November 7, 2008

  • cStringFunctions.cpp - Examples of using c-strings, particularly with strcat, strcmp, strlen and strcpy.
  • fileMatrix.cpp - Example of writing to a file and reading from that file into a file matrix (2-dimentional array of chars.)

Friday, October 30, 2008

Friday, October 23, 2008

Friday, October 17, 2008

Home ethan@cs.ucla.edu
Department of Computer Science, UCLA, Los Angeles, CA 02906
People
hacker emblem
" "
-