changement nom prog c plus changement stdin stdout

This commit is contained in:
quentin.perret 2022-03-24 18:05:37 +01:00
parent 524623e0cd
commit 35d0bd0733
2 changed files with 19 additions and 10 deletions

View file

@ -11,17 +11,27 @@ typedef struct {
int main ( int argc, char **argv)
{
printf("start main");
int i;
char buff[26];
char buff2[18];
int32_t values[8];
uint32_t valbin[8];
quartet value;
while (fread(&buff, 26, 1, stdin)) {
FILE* test = fopen("02400001.TXT","r");
if(test == NULL){
printf("File NULL");
return 1;
}
if(!test){
printf("File opening failed");
return 1;
}
printf("\nbefore while");
while (fread(&buff, 26, 1, test)) { //stdin à la place de test de basetest
/*buff[25] = '\0';*/
if (strncmp(buff, "#################\n", (size_t)18) == 0) {
if (!(fread(&buff2, 18, 1, stdin))) {
if (strncmp(buff, "#################\n", (size_t)18) == 0) {
if (!(fread(&buff2, 18, 1, test))) { // stdin here too
fprintf(stderr, "Erreur lesture après ###...#");
return(1);
} else {
@ -30,10 +40,7 @@ int main ( int argc, char **argv)
strncpy(&buff[8], buff2, 18);
}
}
i = 3;
value.octet1 = buff[3*i+1];
value.octet2 = buff[3*i+2];
value.octet3 = buff[3*i+3];
@ -42,17 +49,19 @@ int main ( int argc, char **argv)
valbin[i] = buff[3*i+1]*256*256*256 + buff[3*i+2]*256*256 + buff[3*i+3]*256;
memcpy(&values[i], &valbin[i], sizeof(int32_t));
if (value.octet1 & 0b10000000) {
printf("Valeur négative trouvée: %02x %02x %02x %d\n", value.octet1, value.octet2, value.octet3, values[i]);
printf("Valeur negative trouvee: %02x %02x %02x %d\n", value.octet1, value.octet2, value.octet3, values[i]);
}
fprintf(stdout, "%02x %02x %02x %d", value.octet1, value.octet2, value.octet3, values[i]/256);
printf("%02x %02x %02x %d", value.octet1, value.octet2, value.octet3, values[i]/256); // stdout au début du printf
/*
for (i=1; i<25; i++) {
fprintf(stdout, "%02x ", buff[i]);
}
*/
printf("\n");
}
// printf("\nend");
}

BIN
hextodec.exe Normal file

Binary file not shown.