Work 3: DEVise a random plan

posted Oct 25, 2016, 2:27 PM by JonAlf Dyrland-Weaver   [ updated Oct 25, 2016, 2:30 PM ]
With a buddy, write a c program with the following features:
  • A function that generates a random int by reading in 4 bytes from /dev/random.
  • A main function that
    1. populates an array with 10 random numbers generated by your random function (print out each value)
    2. writes the array to a file
    3. reads that file into a different array
    4. prints out the contents of the second array to verify the random numbers are the same from step 1
  • Remember to use good practices, like checking return values for errors
  • Also remember to include a makefile that includes a run target (even though this is a single file program)
  • You should be able to read from the array without using a loop.
  • Make sure both team members' names are in the github directory name.

github clone links
https://github.com/mks65/randfile.git
 
Sample output:
Generating random numbers:
        random 0: 198116400
        random 1: 2592608753
        random 2: 2833624368
        random 3: 3273750590
        random 4: 3548697368
        random 5: 3876828898
        random 6: 2617393183
        random 7: 1720936907
        random 8: 682596330
        random 9: 2411695830

Writing numbers to file...

Reading numbers from file...

Verification that written values were the same:
        random 0: 198116400
        random 1: 2592608753
        random 2: 2833624368
        random 3: 3273750590
        random 4: 3548697368
        random 5: 3876828898
        random 6: 2617393183
        random 7: 1720936907
        random 8: 682596330
        random 9: 2411695830

Comments