diff --git a/excercise3/exercise3b.c b/excercise3/exercise3b.c new file mode 100644 index 0000000..3126de5 --- /dev/null +++ b/excercise3/exercise3b.c @@ -0,0 +1,22 @@ +#include +#include + +int main (int argc , char** argv ){ + + // Open file for reading + // We are opening a device file for reading , + // which is like reading from a file but the file is not necessarily an actual file on disk. + // instead it could be some sort of external device or a simple piece of software returning bytes to us + FILE* fp = fopen("/dev/urandom", "r"); + if( !fp){ + perror("File opening failed!"); + return EXIT_FAILURE; + } + + while ( 1 ){ + + printf("Read 0x%x from /dev/urandom\n", fgetc(fp)); + int goAgain ; + scanf("%d", &goAgain); + } +}