Xv6 with picoc & Linkage editor
v1.0
The project delineate mutual cohesion between c library, linkage editor ( linker), interpreter and operating system by porting the same on xv6 kernel
|
00001 #include <stdio.h> 00002 00003 FILE *f = fopen("fred.txt", "w"); 00004 fwrite("hello\nhello\n", 1, 12, f); 00005 fclose(f); 00006 00007 char freddy[7]; 00008 f = fopen("fred.txt", "r"); 00009 if (fread(freddy, 1, 6, f) != 6) 00010 printf("couldn't read fred.txt\n"); 00011 00012 freddy[6] = '\0'; 00013 fclose(f); 00014 00015 printf("%s", freddy); 00016 00017 char InChar; 00018 char ShowChar; 00019 f = fopen("fred.txt", "r"); 00020 while ( (InChar = fgetc(f)) != EOF) 00021 { 00022 ShowChar = InChar; 00023 if (ShowChar < ' ') 00024 ShowChar = '.'; 00025 00026 printf("ch: %d '%c'\n", InChar, ShowChar); 00027 } 00028 fclose(f); 00029 00030 f = fopen("fred.txt", "r"); 00031 while ( (InChar = getc(f)) != EOF) 00032 { 00033 ShowChar = InChar; 00034 if (ShowChar < ' ') 00035 ShowChar = '.'; 00036 00037 printf("ch: %d '%c'\n", InChar, ShowChar); 00038 } 00039 fclose(f); 00040 00041 f = fopen("fred.txt", "r"); 00042 while (fgets(freddy, sizeof(freddy), f) != NULL) 00043 printf("x: %s", freddy); 00044 00045 fclose(f); 00046 00047 void main() {}