Re: File Handling in 'C'
From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 10/08/04
- Next message: Sigurd Stenersen: "Re: C++ compiler and memory"
- Previous message: Larry Brasfield: "Re: File Handling in 'C'"
- In reply to: ChrisP: "File Handling in 'C'"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 8 Oct 2004 00:50:29 -0400
"ChrisP" <ChrisP@discussions.microsoft.com> wrote...
>I need to make a hexdump utility for a Computer Architecture class.
> I haven't had C in 3 years and I just need to open a file and read in a
> line
> of characters.
>
> I am just testing whether it opened the file and got the character, but
> all
> it is displaying is nothing. The file opens correctly, it loops and prints
> "mychar: " the number of times that is equal to the number of characters
> in
> the file, but it wont get the character.
>
> while ((mychar = fgetc(inputfile)) != EOF)
> {
> myArray[counter] = mychar;
> printf("mychar: ",myArray[counter]);
How's it going to print anything if your format doesn't have any
output fields? Perhaps if you do
printf("mychar: %0xu\n", myArray[counter]);
... But then again, I have no idea what 'myArray' is...
RTFM about other printf formats.
> printf("\n");
>
> counter++;
>
> }
>
> Lastly, I have it set to text file read mode. I need to find out if the
> file
> being opened is binary or text and then operate accordingly.
I can't help you with that... Sorry.
V
- Next message: Sigurd Stenersen: "Re: C++ compiler and memory"
- Previous message: Larry Brasfield: "Re: File Handling in 'C'"
- In reply to: ChrisP: "File Handling in 'C'"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|