Moved files of Assignment 1, Started Assignment 2

This commit is contained in:
2020-10-18 21:39:34 +02:00
parent 74c77ecd89
commit 5787d314e0
22 changed files with 205 additions and 0 deletions

View File

@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
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 ){
char random = fgetc(fp);
if ( random == 42 ){
break;
}
printf("Read 0x%x %u %d from /dev/urandom\n", random, random , random);
// getchar();
}
fclose(fp);
}

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
Assignment 1/excercise3/grep Normal file

File diff suppressed because one or more lines are too long

View File

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