Upload files to "verifica_6"
This commit is contained in:
parent
d1efa75fc2
commit
b3ffe2f9e2
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
AUTORE: Manuel Vichi
|
||||
Verifica di Informatica sui file binari
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
typedef struct {
|
||||
int a;
|
||||
float b;
|
||||
} Struct3;
|
||||
|
||||
typedef struct {
|
||||
char nome[12];
|
||||
int eta;
|
||||
float altezza;
|
||||
} Struct6;
|
||||
|
||||
int main(void) {
|
||||
// Inizio del Programma: Apertura del file //
|
||||
FILE* file = fopen("file_3.txt","rb");
|
||||
if (file == NULL) {
|
||||
perror("Errore durante l'apertura del file in lettura");
|
||||
return -1;
|
||||
}
|
||||
// Esercizio 1 //
|
||||
rewind(file);
|
||||
fseek(file,295,SEEK_SET);
|
||||
int int1 = 0;
|
||||
fread(&int1,sizeof(int),1,file);
|
||||
printf("%d\n",int1);
|
||||
// Esercizio 2 //
|
||||
rewind(file);
|
||||
fseek(file,360,SEEK_SET);
|
||||
int offset2 = 0;
|
||||
fread(&offset2,sizeof(int),1,file);
|
||||
rewind(file);
|
||||
//printf("%d\n",offset2);
|
||||
fseek(file,offset2,SEEK_SET);
|
||||
int int2 = 0;
|
||||
fread(&int2,sizeof(int),1,file);
|
||||
printf("%d\n",int2);
|
||||
// Esercizio 3 //
|
||||
rewind(file);
|
||||
fseek(file,491,SEEK_SET);
|
||||
Struct3 struct3;
|
||||
fread(&struct3,sizeof(struct3),1,file);
|
||||
printf("%d %f\n",struct3.a,struct3.b);
|
||||
// Esercizio 4 //
|
||||
rewind(file);
|
||||
fseek(file,491,SEEK_SET);
|
||||
char stringa4[16];
|
||||
fread(&stringa4,sizeof(stringa4),1,file);
|
||||
printf("%s\n",stringa4);
|
||||
// Esercizio 6 //
|
||||
rewind(file);
|
||||
fseek(file,837,SEEK_SET);
|
||||
Struct6 struct6[10];
|
||||
fread(&struct6,sizeof(Struct6),10,file);
|
||||
FILE* file6 = fopen("file6.txt","wt");
|
||||
if (file6 == NULL) {
|
||||
perror("Errore durante l'apertura del file in scrittura");
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < 9; i++) {
|
||||
fprintf(file6,"%s %d %f\n",struct6[i].nome, struct6[i].eta, struct6[i].altezza);
|
||||
}
|
||||
fprintf(file6,"%s %d %f",struct6[9].nome, struct6[9].eta, struct6[9].altezza);
|
||||
fclose(file6);
|
||||
file6 = fopen("file6.txt","rb");
|
||||
uint8_t buffer[256];
|
||||
uint8_t checksum = 0;
|
||||
int read = fread(&buffer,sizeof(uint8_t),256,file6);
|
||||
if (read == 0) {
|
||||
perror("Errore durante la lettura");
|
||||
fclose(file);
|
||||
fclose(file6);
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < read; i++) {
|
||||
checksum += buffer[i];
|
||||
}
|
||||
printf("%d\n",checksum);
|
||||
fclose(file6);
|
||||
// Fine del programma: chiusura del file di lettura e scrittura dei risultati su un file txt //
|
||||
fclose(file);
|
||||
FILE* results = fopen("results.txt","wt");
|
||||
if (file == NULL) {
|
||||
perror("Errore durante l'apertura del file dei risultati");
|
||||
return -1;
|
||||
}
|
||||
fprintf(results, "int1: %d\n",int1);
|
||||
fprintf(results, "int2: %d\n",int2);
|
||||
fprintf(results, "a: %d; b : %f\n",struct3.a,struct3.b);
|
||||
fprintf(results, "stringa4: %s\n",stringa4);
|
||||
fprintf(results, "checksum: %d\n",checksum);
|
||||
fclose(results);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
kjCPsXriV0 R ðRHLHOBmebXc1 Æ @j5GrYEBtANhR2 BA €ÁBGjmPHRzxhT3 ¢õ €{GXKvZxmEpn4 Êæ @GOgSTAjlpP5 ÀHÛGYZdFvzhaQ6 H <20>iHbwjZPHBoR7 Ÿ ‹¿GnaJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537350659 215551.750000
|
||||
LHOBmebXc1 Æ @j5GrYEBtANhR2 BA €ÁBGjmPHRzxhT3 ¢õ €{GXKvZxmEpn4 Êæ @GOgSTAjlpP5 ÀHÛGYZdFvzhaQ6 H <20>iHbwjZPHBoR7 Ÿ ‹¿GnaJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537206982 46442.250000
|
||||
rYEBtANhR2 BA €ÁBGjmPHRzxhT3 ¢õ €{GXKvZxmEpn4 Êæ @GOgSTAjlpP5 ÀHÛGYZdFvzhaQ6 H <20>iHbwjZPHBoR7 Ÿ ‹¿GnaJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537870658 49857.500000
|
||||
jmPHRzxhT3 ¢õ €{GXKvZxmEpn4 Êæ @GOgSTAjlpP5 ÀHÛGYZdFvzhaQ6 H <20>iHbwjZPHBoR7 Ÿ ‹¿GnaJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537130402 34171.500000
|
||||
XKvZxmEpn4 Êæ @GOgSTAjlpP5 ÀHÛGYZdFvzhaQ6 H <20>iHbwjZPHBoR7 Ÿ ‹¿GnaJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537519818 34822.250000
|
||||
OgSTAjlpP5 ÀHÛGYZdFvzhaQ6 H <20>iHbwjZPHBoR7 Ÿ ‹¿GnaJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537271300 112273.500000
|
||||
YZdFvzhaQ6 H <20>iHbwjZPHBoR7 Ÿ ‹¿GnaJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537664328 239168.500000
|
||||
bwjZPHBoR7 Ÿ ‹¿GnaJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537829147 98071.250000
|
||||
naJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537034189 30406.250000
|
||||
aDOKEFcme9 í<> ÒHŽ* @\éÇ|G”GÜFVŽ* @\éÇ 537038317 158536.250000
|
|
@ -0,0 +1,11 @@
|
|||
offset1: 295
|
||||
offset2: 360
|
||||
offset3: 491
|
||||
offset4: 609
|
||||
offset5: [657,672,684,694,697,715,722,735]
|
||||
offset6: 837
|
||||
sizeof(info): 126
|
||||
u/Ô ('}'µÂjüÞÚÌåËÈx«ix#Œ4Œž)ÓJËÍur(üÐ=ãHuíq¨N²£‚FãJp÷^„à.d<>ŒÊÍü°
êÐØg뢋¥9;÷òZÏü#‡"€Aá2::Ÿìš¿_<ûíÒ5º0”:a±ïÜÑ÷ RÝ,YìàO\zz#<23>!áIA᪰kü€Œy„'<27>øñbÞ´üh<C3BC>LI:¡ <C2A1>‰É 2
|
||||
+)¿ì€+ü¥òƒL=:…./7[,tðR¥b€æsIlɵ˜šƒH£ã÷Å<0E>÷σ”£×Ö”f0rí|– G;–~"›'áÈ-œêÛ€!ƒjxfͳýätöl»¿XuO‹¸ðq!<21>†%’ ~±©Z
|
||||
D<úP<C3BA>‚ý‘JiZâ裩 ]wÄdVÓ61‰,‚ÀƒF{PF#Áläjëž¡7Þ<37>І,¬ê<9ÏF¯S.O’#ø8~£Ç Ž* @\éÇ|G”GÜFV =¿à~;ÑŽîúbïÒà]$·b@7f{*¬øÀ/±)ûø±àiãð«IÈW.ÓïÂ$ql4%ü½>°÷—»›&‰G‘¼<E28098>åý*ÓR¼5téz…cR/[
‰zŒ„P9<!^5D@wyCA7BT~\rTQ Ÿ”«—'us¯´üç4ˆ8ñ²7›»Öȶór´úï‡@€»¼³ÅŠ•óüåâzF;¹L'.ÉHei²’À€áúñ§e¢)úJÜw!`¦×ƒ—…!nŸw“bc¾“¨mcט@º·?â>‰åRœw¼–Auq2Þ
|
||||
ײo áÅ2©–‚´€ßñÛ_ºVY‹A/Ý”ü²2woH•NË<4E>‰vü¯Õbó…£0êÏ(›î¨³½ ²Î¸±‡µ·¾g¢¿ÍUº©"Ž”¿.ò~ß'ž`Ó½¾/kjCPsXriV0 R ðRHLHOBmebXc1 Æ @j5GrYEBtANhR2 BA €ÁBGjmPHRzxhT3 ¢õ €{GXKvZxmEpn4 Êæ @GOgSTAjlpP5 ÀHÛGYZdFvzhaQ6 H <20>iHbwjZPHBoR7 Ÿ ‹¿GnaJhYXbQD8 Í} €ŒíFaDOKEFcme9 í<> ÒH
|
|
@ -0,0 +1,5 @@
|
|||
int1: 537532210
|
||||
int2: 0
|
||||
a: 537275022; b : -119480.500000
|
||||
stringa4: Ž* @\éÇ|G”GÜFVŽ* @\éÇ
|
||||
checksum: 211
|
Loading…
Reference in New Issue