Last part of assignment 1

This commit is contained in:
2020-10-17 23:09:33 +02:00
parent b1e1727f28
commit 74c77ecd89
5 changed files with 141892 additions and 4 deletions

View File

@ -14,9 +14,13 @@ int main (int argc , char** argv ){
}
while ( 1 ){
printf("Read 0x%x from /dev/urandom\n", fgetc(fp));
int goAgain ;
scanf("%d", &goAgain);
char random = fgetc(fp);
if ( random == 42 ){
break;
}
printf("Read 0x%x %u %d from /dev/urandom\n", random, random , random);
// getchar();
}
fclose(fp);
}

26
excercise3/exercise3d.c Normal file
View File

@ -0,0 +1,26 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
int main (int argc , char** argv){
uint16_t number;
FILE* urandomFile = fopen( "/dev/urandom" , "r");
if( !urandomFile ){
perror("Could not open file for reading...");
return EXIT_FAILURE;
}
while(1){
fread( &number, sizeof(uint16_t), 1, urandomFile);
if( number == 42){
break;
}
printf( "0x%x %u %d\n" , number, number, number );
}
fclose(urandomFile);
}

141633
excercise3/grep Normal file

File diff suppressed because one or more lines are too long

10
excercise3/lines.txt Normal file
View File

@ -0,0 +1,10 @@
1537
12731
5948
56298
162176
13281
18465
97358
172118
115888