changement nom prog c plus changement stdin stdout
This commit is contained in:
parent
524623e0cd
commit
35d0bd0733
|
@ -11,17 +11,27 @@ typedef struct {
|
||||||
|
|
||||||
int main ( int argc, char **argv)
|
int main ( int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
printf("start main");
|
||||||
int i;
|
int i;
|
||||||
char buff[26];
|
char buff[26];
|
||||||
char buff2[18];
|
char buff2[18];
|
||||||
int32_t values[8];
|
int32_t values[8];
|
||||||
uint32_t valbin[8];
|
uint32_t valbin[8];
|
||||||
quartet value;
|
quartet value;
|
||||||
|
FILE* test = fopen("02400001.TXT","r");
|
||||||
while (fread(&buff, 26, 1, stdin)) {
|
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';*/
|
/*buff[25] = '\0';*/
|
||||||
if (strncmp(buff, "#################\n", (size_t)18) == 0) {
|
if (strncmp(buff, "#################\n", (size_t)18) == 0) {
|
||||||
if (!(fread(&buff2, 18, 1, stdin))) {
|
if (!(fread(&buff2, 18, 1, test))) { // stdin here too
|
||||||
fprintf(stderr, "Erreur lesture après ###...#");
|
fprintf(stderr, "Erreur lesture après ###...#");
|
||||||
return(1);
|
return(1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,10 +40,7 @@ int main ( int argc, char **argv)
|
||||||
strncpy(&buff[8], buff2, 18);
|
strncpy(&buff[8], buff2, 18);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
i = 3;
|
i = 3;
|
||||||
|
|
||||||
value.octet1 = buff[3*i+1];
|
value.octet1 = buff[3*i+1];
|
||||||
value.octet2 = buff[3*i+2];
|
value.octet2 = buff[3*i+2];
|
||||||
value.octet3 = buff[3*i+3];
|
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;
|
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));
|
memcpy(&values[i], &valbin[i], sizeof(int32_t));
|
||||||
|
|
||||||
if (value.octet1 & 0b10000000) {
|
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++) {
|
for (i=1; i<25; i++) {
|
||||||
fprintf(stdout, "%02x ", buff[i]);
|
fprintf(stdout, "%02x ", buff[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
// printf("\nend");
|
||||||
}
|
}
|
BIN
hextodec.exe
Normal file
BIN
hextodec.exe
Normal file
Binary file not shown.
Loading…
Reference in a new issue