Re: File Handling in 'C'

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 10/08/04


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



Relevant Pages

  • Is there a list of error numbers for G77 ???
    ... using a character * 255 variable. ... It opens the file OK, but gets an error on the first read, ... character * 255 inputline ...
    (comp.os.msdos.djgpp)
  • Re: Two Human Targets, two weeks
    ... What really sells it is that you half believe him. ... I liked the preview clip too...telling the cops as he opens the ... any explaination is there-it is the same for the show. ... watching a character that they love to hate (and imagine ...
    (rec.arts.tv)
  • Re: Two Human Targets, two weeks
    ... I liked the preview clip too...telling the cops as he opens the ... any explaination is there-it is the same for the show. ...  This one is just for fun. ... watching a character that they love to hate (and imagine ...
    (rec.arts.tv)
  • Re: Form - open subform code
    ... > opens the form, but you said there is something wrong. ... FROM tblContacts INNER JOIN (tblClaims INNER JOIN tblReturns ON ... , go into tblReturns, enter a character somewhere, go back into ... press my button on the subform and the correct record shows. ...
    (microsoft.public.access.formscoding)