B
Bill Cunningham
I worked and worked on this code until my compiler gave no more errors
even with -Wall -ansi turned on. So I think it's valid. The question is is
it doing what I want it to. I don't think so. Its never stopped and I've had
to interrupt it while running. I get a bunch of textual 00 all across the
screen. The idea is to take a binary and convert it to text and print it in
hex. I never get out of the do-while loop. Like a hex dump does but a hex
dump doesn't convert a binary into text. Is what I'm wanting valid? Am I
getting what I'm asking for. Here's the code if your reader lets you read it
neatly.
Bill
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int buf[8200];
unsigned buf2[8200];
FILE *fp, *fp2;
if ((fp = fopen("6", "rb")) == NULL) {
perror("fopen 1");
exit(1);
}
if ((fp2 = fopen("b", "wt")) == NULL) {
perror("fopen 2");
exit(1);
}
do {
*buf = fscanf(fp, "%i", buf);
fprintf(fp2, "%i %x", *buf, *buf2);
}
while (*buf != EOF);
fclose(fp);
fclose(fp2);
printf(" %i %u", *buf, *buf2);
return 0;
}
even with -Wall -ansi turned on. So I think it's valid. The question is is
it doing what I want it to. I don't think so. Its never stopped and I've had
to interrupt it while running. I get a bunch of textual 00 all across the
screen. The idea is to take a binary and convert it to text and print it in
hex. I never get out of the do-while loop. Like a hex dump does but a hex
dump doesn't convert a binary into text. Is what I'm wanting valid? Am I
getting what I'm asking for. Here's the code if your reader lets you read it
neatly.
Bill
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int buf[8200];
unsigned buf2[8200];
FILE *fp, *fp2;
if ((fp = fopen("6", "rb")) == NULL) {
perror("fopen 1");
exit(1);
}
if ((fp2 = fopen("b", "wt")) == NULL) {
perror("fopen 2");
exit(1);
}
do {
*buf = fscanf(fp, "%i", buf);
fprintf(fp2, "%i %x", *buf, *buf2);
}
while (*buf != EOF);
fclose(fp);
fclose(fp2);
printf(" %i %u", *buf, *buf2);
return 0;
}