Topic: HELP! File processing/direct access problem


Author: hbcsc288@huey.csun.edu (Ron Calderon)
Date: 8 Feb 1995 06:50:43 GMT
Raw View
           Help! I need to know how to do these in C++ for a class
        excercise.  (I know I'm supposed to do this myself, but I these
        involve file-processing, and the class I took that was a pre-
        requisite for this class *never* covered *any* file-processing,
        and the textbook certainly was a *lot* help.....)

        you have an integer N...

        how do you create a file of N*N+1 records, where each
        record has 3 fields.  (I know how to do this with a
        "struct"...but structs only work in main memory and not
        in files...at least as far as I've been taught.)

          Anyway here's the exact wording of the problem as it appears
        in my handout sheet: (case you're curious, this is for a "magic
        square" program)

          Ask for an interger N (N must be odd, greater than 1) and
        creates a file of N*N+1 records. Each record has 3 fields:
        (row, column, value).
          Record number 0 contains (0, 0, N).
        The next N*N records are the elements from the "magic square"
        of the order N in the following sequence: first all elements
        from row number 1 (from left to right), after this all elements
        from row number 2 (from left to right), then all the elements
        from row number 3..., and finally all the elements from row
        number N (from left to right) using a direct access to a file.


        *please nobody give me any algorithms for creating the magic
        square (ruin all my fun, will you!) :-), just the file creating,
        and direct access stuff. thanks in advance :)

        Ron :D